2015-05-20 14:19:52.306655 hello
2015-05-20 14:19:55.406846 hello
2015-05-20 14:19:57.292777 hello
The log file was generated on a Godaddy shared linux hosting account using this code:
with open( log_path, 'a' ) as f:
f.write( '%s hello\n'%datetime.now() )
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
var range='1-';
$.ajax( 'log.log', {
dataType: "text",
cache: false,
headers: {Range: "bytes=" + range},
success: function (data, s, xhr) {
console.log( data );
},
error: function (xhr, s, t) {
loading = false;
if (xhr.status === 416 || xhr.status == 404) {
/* 416: Requested range not satisfiable: log was truncated. */
/* 404: Retry soon, I guess */
console.log( xhr.status)
} else {
throw "Unknown AJAX Error (status " + xhr.status + ")";
}
}
});
</script>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
Now, when I open the html page, I get an ERR_CONTENT_DECODING_FAILED error from the Javascript console.
I do not get that error if I only write to the log file twice (i.e. it only has 2 line in it, rather than 3).
What is causing the problem and how can I avoid it? Ideally I would like to use Python's logging API rather than file.write, but it gives the same error as well.
I am using Google Chrome on a Lubuntu machine.
However, curl retrieves the data successfully and returns no error.