Method Protocols.HTTP.quoted_string_encode()


Method quoted_string_encode

string quoted_string_encode(string s)

Description

Encodes the given string quoted to be used as content inside a quoted-string according to RFC 2616 section 2.2. The returned string does not include the surrounding " chars.

Note

The quoted-string quoting rules in RFC 2616 have several problems:

  • Quoting is inconsistent since " is quoted as \", but \ does not need to be quoted. This is resolved in the HTTP bis update to mandate quoting of \ too, which this function performs.

  • Many characters are not quoted sufficiently to make the result safe to use in an HTTP header, so this quoting is not enough if s contains NUL, CR, LF, or any 8-bit or wider character.

See also

quoted_string_decode