Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: linefeed conversion
Pages: [1] Print
Author Topic: linefeed conversion  (Read 399 times)
fhein
Newbie
*
Offline Offline

Posts: 47


View Profile
linefeed conversion
« on: May 09, 2005, 05:51:27 PM »

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
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
linefeed conversion
« Reply #1 on: May 10, 2005, 04:46:47 AM »

If you don't want the conversion for the contents, set the port to binary mode after sending the header. I.e.:

Code:
set-modes port [binary: true]
Logged
fhein
Newbie
*
Offline Offline

Posts: 47


View Profile
linefeed conversion
« Reply #2 on: May 10, 2005, 05:26:07 PM »

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
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
linefeed conversion
« Reply #3 on: May 11, 2005, 05:30:38 AM »

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
Newbie
*
Offline Offline

Posts: 47


View Profile
linefeed conversion
« Reply #4 on: May 11, 2005, 05:30:00 PM »

didn't think of that Tongue 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
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
linefeed conversion
« Reply #5 on: May 12, 2005, 05:28:21 AM »

Yes, you can send just "^/" for HTML. A browser that breaks is a bugged browser. Wink

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
Newbie
*
Offline Offline

Posts: 47


View Profile
linefeed conversion
« Reply #6 on: May 12, 2005, 10:00:05 PM »

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] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: linefeed conversion
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2008, 09:03:42 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2287 Posts in 593 Topics by 3725 Members
Latest Member: Heigueundulge

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc