summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/packet_parser.h
diff options
context:
space:
mode:
authorMatyas Markovics <matyas@scrapinghub.com>2019-11-24 13:44:48 +0100
committerMatyas Markovics <matyas@scrapinghub.com>2019-11-24 13:44:48 +0100
commite7cd437733489a882f0e7f278a1a854bee7b6e6b (patch)
tree083ca44059d0145d63e8257f8497deef78bb36e7 /erts/emulator/beam/packet_parser.h
parent887eb6ee7cb44df0c8f02c5b8e8455bc96b83b33 (diff)
downloaderlang-e7cd437733489a882f0e7f278a1a854bee7b6e6b.tar.gz
Change Reserved to unmodified HTTP header-field
Propagate unmodified header fields in the previously Reserved and undefined 4th element of the http_header tuple. *Why do we need this new feature?* While Section 4.2 of RFC 2616 for HTTP/1.1 states that Field names are case-insensitive, some non-compliant web services may rely on peculiar casing of Field names. Such web-services cannot be accessed through a Proxy-server, that is implemented in Erlang/OTP, certainly not over HTTPS. Despite the RFC, even the IANA lists a number of permanently registered headers in all-caps or mixed-cased format, e.g.: ALPN, HTTP2-Settings, WWW-Authenticate, etc. This leads to confusion and to service implementations, that only accept headers formatted the same way. A production issue was experienced using the common, drafted, but not yet standard header: DNT. There are a number of HTTP servers implemented in Erlang that could be used in a Proxy implementation. However, there is none that would respect header-casing. * cowboy, httpd - their header parser lower-cases the fields * yaws - emulators' internal HTTP header parsing via ssl/inet * mochiweb, elli - both use erlang:decode_packet/3 As a side note: An HTTPS-Proxy requires CONNECT method support. Therefor cowboy is not a real option despite its popularity. With this proposal yaws, mochiweb and elli could all be patched to respect casing of header fields and propagate the original header format to the application level modules. The DNT header issue was experienced using a patched mochiweb. *Risks or uncertain artifacts?* These changes are minimalistic and backward compatible, given application developers respected the documentation. All above mentioned http servers do so, they ignore the 4th element of http_header tuple. It was verified in the master branches of the project repositories. *How did you solve it?* The proposal is that packet_parser.c should also propagate unmodified fields to both inet_drv.c and erl_bif_port.c, where these would be put in the 4th place of the http_header tuple. Its recognised, that this element was Reserved for future and/or internal use. Hopefully you'd agree, that sending the original header fields is a productive use-case to free up the reservation. Adding a new httph_cs option, cs for case-sensitive, was also considered. I got the impression thought, that these these packet decoders exit for compatibility reasons only and the OTP-Team is not keen on adding new options.
Diffstat (limited to 'erts/emulator/beam/packet_parser.h')
-rw-r--r--erts/emulator/beam/packet_parser.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/erts/emulator/beam/packet_parser.h b/erts/emulator/beam/packet_parser.h
index 358d650804..b05623efec 100644
--- a/erts/emulator/beam/packet_parser.h
+++ b/erts/emulator/beam/packet_parser.h
@@ -77,8 +77,10 @@ typedef int HttpResponseMessageFn(void* arg, int major, int minor, int status,
typedef int HttpRequestMessageFn(void* arg, const http_atom_t* meth, const char* meth_ptr,
int meth_len, const PacketHttpURI*, int major, int minor);
typedef int HttpEohMessageFn(void *arg);
-typedef int HttpHeaderMessageFn(void* arg, const http_atom_t* name, const char* name_ptr,
- int name_len, const char* value_ptr, int value_len);
+typedef int HttpHeaderMessageFn(void* arg, const http_atom_t* name,
+ const char* name_ptr, int name_len,
+ const char* oname_ptr, int oname_len,
+ const char* value_ptr, int value_len);
typedef int HttpErrorMessageFn(void* arg, const char* buf, int len);
typedef int SslTlsFn(void* arg, unsigned type, unsigned major, unsigned minor,
const char* data, int len, const char* prefix, int plen);