26

As I know, use LF as line delimiter is quite popular, but I'm wondering why many text protocol like HTTP, FTP use CRLF as its line delimiter?

I don't think these protocols are invented for old typewriters, so is there any historic reason for this? I tried to search it over google and stackoverflow and wikipedia but do not get any reasonable information.

Thanks

otakustay
  • 11,817
  • 4
  • 39
  • 43
  • 1
    I would say simply because Microsoft Dos and Windows were most popular operating systems, so client programs from these systems were most used. After all home use of unix-like systems is much younger than use of any others.. And who may know why LF was "not good" so Microsoft "insisted" on CRLF in their products? – Piotr Wadas Jun 23 '13 at 16:28
  • 2
    Adding on to what @PiotrWadas said ... the spec also [recommends applications be tolerant and accept `LF` line delimiters](http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.3) so the official status of `CRLF` as the line delimiter doesn't really mean very much. This tolerance is particularly helpful for situations like telnet where you can simply press enter when manually composing a raw message regardless of the OS from which you're working. –  Jun 23 '13 at 18:44
  • 1
    @PiotrWadas but the first machines using http were Unix like (NeXT) also CRLF probably predates use of just CR – mmmmmm Jun 23 '13 at 21:32

1 Answers1

19

CR-LF as newline is the Internet standard, which long predates HTTP; I believe it was originally specified as part of TELNET in RFC 158 in 1971. The RFC Editor has a page explaining some of the history. This is the convention used by other Internet protocols such as FTP and SMTP, so it only makes sense for HTTP to be consistent with them.

Community
  • 1
  • 1
Simon Kissane
  • 4,373
  • 3
  • 34
  • 59
  • 1
    Even new protocols like Redis make use of this CR-LF convention. – laurent May 08 '17 at 13:13
  • 1
    I believe that RFC 5198 "Unicode Format for Network Interchange" is also relevant. – beroal Dec 10 '19 at 13:04
  • 1
    The RFC Editor EOL history: "Many today use Windows, based on MS-DOS, which came along later and adopted CR LF as its EOL convention.". This is interesting! So, Microsoft did not "invent" CR-LF but adpoted it! – eikuh Mar 12 '21 at 11:21
  • 2
    @eikuh Yes Microsoft 's MS-DOS took it from Digital Research CP/M, which in turn very likely copied it from DEC operating systems (especially, the TOPS-10 operating system for the DEC PDP-10, which Gary Kildall used when writing CP/M). The fact that it is the Internet standard is independent of Microsoft's adoption of it – Microsoft wasn't even founded until 4 years later – but DEC systems were very popular in the early Internet, which may have influenced the choice of CR-LF as the Internet standard – Simon Kissane Mar 12 '21 at 22:22