Sending folded SIP header fields

Tabs are perfectly legal, and CR LF is legal, but LF is not. E.g.:

SIP header field values can be folded onto multiple lines if the continuation line begins with a space or horizontal tab. All linear white space, including folding, has the same semantics as SP. A recipient MAY replace any linear white space with a single SP before interpreting the field value or forwarding the message downstream. This is intended to behave exactly as HTTP/1.1 as described in RFC 2616 [8]. The SWS construct is used when linear white space is optional, generally between tokens and separators.

LWS = [*WSP CRLF] 1*WSP ; linear whitespace
SWS = [LWS] ; sep whitespace

See RFC 3261: SIP: Session Initiation Protocol Note that this does mean that line folding is directly in the SIP RFC.

RFC 2616 defines CRLF as:

CRLF = CR LF

and defines LWS, directly in terms of tab and space:

LWS = [CRLF] 1*( SP | HT )

There is a recommendation not to actually look for the CR and to treat LF as CR LF.