Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reusing the response object #772

Closed
Closed
@maingoh

Description

@maingoh

I am implementing the follow_redirects using the async_client and when I reuse the same response object, the body is updated but not the headers.

Sample:

intmain() {    std::string url ="http://google.com";    async_client::options options;    options       .follow_redirects(true)       .cache_resolved(true)       .always_verify_peer(false)       ;    async_clientclient(options);    async_client::requestreq(url);auto response = client.get(req));while (!ready(response));// we get the expected headers and bodyauto hdrs =headers(response);for (auto &h : hdrs) {LOG(INFO) << h.first <<":" << h.second;    }LOG(INFO) <<body(response);LOG(INFO) <<"-----------------";    req.uri("http://example.com");// changing the url    response = client.get(req));while (!ready(response));// here the headers are the same as the previous response, they should be those from example.comauto hdrs2 =headers(response);for (auto &h : hdrs2) {LOG(INFO) << h.first <<":" << h.second;    }// the body is the body of example.comLOG(INFO) <<body(response);}

I tried the swap method without success.
Weirdly I manage to make it working using smart_ptr like this :

response.reset(new async_client::response(client.get(req)));

Is there an explication or is it a bug ? If this is normal it should probably be explained in the documentation.

Also I had a similar problem with the request object (operator= didn't work), but using the swap method I made it working.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp