|
Pages: [1]
|
 |
|
Author
|
Topic: linefeed conversion (Read 399 times)
|
|
fhein
|
I'm currently writing a http-server (on top of a slightly modified HIPE) and I'm having some problems with the automatic linefeed conversion that happens when I insert text into a port. The problem comes from that I want to print content-length in the header that I send to the client, but length? content gives the length before crlf conversion, which causes the end of the document to get lost. Is the best method to solve this to use binary ports and handle conversion manually?
Also, I'd be thankful if someone could give me a link or two to resources related to setting up a minimal http server.
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
If you don't want the conversion for the contents, set the port to binary mode after sending the header. I.e.: set-modes port [binary: true]
|
|
|
|
|
Logged
|
|
|
|
|
fhein
|
Just to make sure, would the correct manual linefeed conversion command be:
replace/all content newline #{0D0A}
and I only need to convert "text/*" files?
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
Yes, that should work. However, HTTP content does not have to be terminated by CRLF. (Headers have to be terminated by CRLF, but not content.) Text content (i.e. text/*) can be terminated by anyone of CR, LF, or CRLF, and clients should support any of this. For example, browsers don't matter if the HTML is terminated by just LF or CRLF.
So, unless you have a specific need, you can avoid doing the conversion if you're writing a HTTP server.
|
|
|
|
|
Logged
|
|
|
|
|
fhein
|
didn't think of that  so I can send regular "^/" even if I use <pre> somewhere? don't have any non-windows platforms to experiment with (really wish I had a network card for my A4k though). do you by any chance know if the content-length: is necessary when sending regular html-pages? explorer seems to ignore it anyhow..
|
|
|
|
« Last Edit: May 11, 2005, 05:33:12 PM by fhein »
|
Logged
|
|
|
|
|
Gabriele
|
Yes, you can send just "^/" for HTML. A browser that breaks is a bugged browser.  About Content-Length: it is optional for HTTP 1.0 responses, but should always be there for HTTP 1.1; anyway, if you don't support Keep-Alive, you don't need to supply a Content-Length as clients will know the end of the response by you closing the connection. So... you're quite safe if you don't send it in normal cases.
|
|
|
|
|
Logged
|
|
|
|
|
fhein
|
I intend to support keep-alive in the future, unless it requires too much modding of HIPE.. but it's postponed until I think I have time to spare for optimizations
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2287 Posts in 593 Topics by 3725 Members
Latest Member: Heigueundulge
|