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

How to read the request headers in web::http::http_request #1525

Open
Darker opened this issue Oct 27, 2020 · 3 comments
Open

How to read the request headers in web::http::http_request #1525

Darker opened this issue Oct 27, 2020 · 3 comments

Comments

@Darker
Copy link

@Darker Darker commented Oct 27, 2020

The class allows me to set HTTP response headers via headers(), but I would like to read the request headers. How can I do that?

@SirPustekuchen
Copy link

@SirPustekuchen SirPustekuchen commented Nov 2, 2020

For example you can iterate over all headers in a response object this way:

for (const auto& header : response.headers())
	sHeaders += header.first + U(": ") + header.second;
@Darker
Copy link
Author

@Darker Darker commented Nov 2, 2020

I want to read request headers when handling a HTTP requests.

@SirPustekuchen
Copy link

@SirPustekuchen SirPustekuchen commented Nov 3, 2020

It's the same, e.g.

web::http::http_request request;
...
string_t sHeaders;
for (const auto& header : request.headers())
	sHeaders += header.first + U(": ") + header.second;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.