Hashemian Blog
Web, Finance, Technology

Add Newline After SSI (Server Side Include)

by @ 4:00 pm
Filed under: web — Tags: , , ,

Recently I noticed that my Chrome browser was having issues displaying some of the web pages on this site. The pages wouldn't load at all or would only load partially.

After some investigating it turned out that those pages were of SSI type, usually having extensions .shtml or .shtm. Such pages could also have other extensions depending on the system configuration.

Figuring out and fixing the problem however took a number of frustrating hours. On this server, Apache has KeepAlive turned on. That means for most browsers the content is sent using chunked transfer encoding and that means the browser and server maintain an open connection for some time as data is passed in. That saves on resources and gives the server more flexibility in data transmission but on the flip side the server needs to calculate and send the content length to the browser for each chunk. Without the correct content length, browsers won't be able to correctly display the page.

After hours of trial and error, I noticed that these pages had an include such as below at their tail end with nothing after that, no newlines, no characters, nothing.

<!--#include virtual="/some_file.inc" -->

The Chrome debugger would show a red failure loading for the page but there was no explanation. cURL however came in handy, displaying this error at the end:

error 18: transfer closed with outstanding read data remaining

That's when the underlying issue revealed itself, sort of. Obviously the server wasn't sending the correct content length or the terminating chunk to the browser causing the failure. The fix came by luck after I added a few characters at the tail end of the file. Turns out that adding a single space or newline character was enough to fix the error.

At this point I have no idea why this flaw exists in the first place and why adding a character at the end of the file fixes the issue. But if you are running into the same problem, try the same solution and see if it helps, and don't underestimate the power of cURL to debug these types of issues.

Blocking Referrer (Referer) Header in Chrome

by @ 10:43 pm
Filed under: google,web — Tags: , ,

NOREF Chrome ExtensionI have been using the Google Chrome browser for quite a while now but the inability to block the Referrer header in Chrome has been a concern. Well, it was a concern until this past weekend when I got tired of waiting and wrote a Chrome extension to suppress it.

I don't think Referer can be easily blocked in IE either, but in Firefox you surf to about:config and then set the network.http.sendRefererHeader parameter to 0.

Now you can do the same in Chrome by installing the NOREF Chrome extension. It uses the new HTML5 feature for blocking referer transmission by adding a "rel=noreferrer" attribute to every link after a web page finishes loading. I've tested it lightly and so far so good. Let me know how it works out for you.

Powered by

Read Financial Markets  |   Home  |   Blog  |   Web Tools  |   News  |   Articles  |   FAQ  |   About  |   Privacy  |   Contact
Donate Bitcoin: 1GfrF49zFWfn7qHtgFxgLMihgdnVzhE361
© 2001-2022 Robert Hashemian   Powered by Hashemian.com