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

Impossible to access all Set-Cookie headers #37

Closed
01e9 opened this issue Jan 24, 2018 · 4 comments
Closed

Impossible to access all Set-Cookie headers #37

01e9 opened this issue Jan 24, 2018 · 4 comments
Assignees
Labels

Comments

@01e9
Copy link
Contributor

01e9 commented Jan 24, 2018

In response I have multiple cookies but Reply::GetHeader(name) returns only the last header with the give name

/*! Get the value of a header */
virtual boost::optional<std::string>
GetHeader(const std::string& name) = 0;

Until this will be fixed, any workaround?

@jgaa jgaa self-assigned this Jan 24, 2018
@jgaa jgaa added the bug label Jan 24, 2018
@01e9
Copy link
Contributor Author

01e9 commented Feb 7, 2018

I just found that restbed has a http client (this is my workaround).
Much simpler to use and has a get_headers() method that returns a multimap.

std::string uri {"http://localhost/test"};
std::string body {"{\"foo\":\"bar\"}"}

auto request = std::make_shared<restbed::Request>(restbed::Uri{uri});
request->set_method("POST");
request->set_headers({{"Content-Length", std::to_string(body.size())}});
request->set_body(body);

auto response {restbed::Http::sync(request)};

auto cookieHeaders {response->get_headers("Set-Cookie")};

std::string responseBody {
    restbed::String::to_string(
        restbed::Http::fetch(
            std::stoi(response->get_header("Content-Length")), 
            response
        )
    )
};

@jgaa
Copy link
Owner

jgaa commented Feb 8, 2018

I have not implemented dedicated support for cookies yet. It will be done soon. The last few weeks I have worked on another project, including some Jenkins CI work.
Currently it's too much work to test new features on all the platforms I support with restc-cpp. That has held the progress back.
One of the next days I will setup automatic builds and tests for all the platforms supported, and after that I will fix the bugs and move the project forward.

@01e9
Copy link
Contributor Author

01e9 commented Feb 8, 2018

I have not implemented dedicated support for cookies yet.

I haven't asked support for cookies. It's just an example of multi-header value.

@jgaa
Copy link
Owner

jgaa commented Feb 8, 2018

Yes, I'll fix that as well :)
Cookies has been on my list for a while, I just never needed it myself.

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

No branches or pull requests

2 participants