Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The http_listener remaps the Date header to Data #1208

Closed
ghost opened this issue Jul 29, 2019 · 2 comments · Fixed by #1219
Closed

The http_listener remaps the Date header to Data #1208

ghost opened this issue Jul 29, 2019 · 2 comments · Fixed by #1219

Comments

@ghost
Copy link

ghost commented Jul 29, 2019

When receiving a request with the cpprestsdk http_listener, the Date header from the sent request is mapped to the Data header in the http_request of cpprestsdk.

According to line 47 in Release/src/http/listener/http_server_httpsys.cpp, the values of HttpServerAPIKnownHeaders are supposed to match the values of the _HTTP_HEADER_ID enum (defined here). HttpServerAPIKnownHeaders states Data as the third entry, whereas _HTTP_HEADER_ID lists Date.

If someone could please verify that the issue is indeed present and that the cuplrit is the suggested typo, I would gladly provide a pullrequest to be merged into this project.

@garethsb
Copy link
Contributor

garethsb commented Jul 29, 2019

I agree, that looks like a typo!!

At the same time, it would be nice to fix "Content-Md5", "Etag" and "Www-Authenticate" to the canonical "Content-MD5", "ETag" and "WWW-Authenticate" slightly further down the same file, even though header names are compared case-insensitively.

And all these fixes should please also be applied to Release\tests\functional\http\utilities\test_http_server.cpp.

@garethsb
Copy link
Contributor

garethsb commented Aug 6, 2019

Actually, the HttpServerAPIKnownHeaders is more broken than it first appears, since the HTTP Server API HTTP_HEADER_ID is not a simple auto-numbered enum but rather includes common, and request- and response-specific headers in a single enum with constant initializers for the defined indices in the HTTP_REQUEST_HEADERS::KnownHeaders and the HTTP_RESPONSE_HEADERS::KnownHeaders arrays. For example, both HttpHeaderAcceptCharset (the request header, "Accept-Charset") and HttpHeaderAge (the response header, "Age") are given the same value, 21.

As it stands, HttpServerAPIKnownHeaders is only used to parse request headers, so rather than create a new structure that works for both, I propose to remove the response-specific headers and clarify its intended use. PR on its way...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant