Skip to content

Cancel http::client::fetch()? #3

@mincequi

Description

@mincequi

Hi there and thanks for this lib!

I got a question regarding the following scenario:
Imagine I am wrapping the client in another class which does a request.
Before the request finishes, the wrapping object gets destroyed which results in a segfault.
So, I need to cancel the request before destroying the object. How would I do that?

Thanks a lot in advance!

class SomeClass {
public:
  ~SomeClass() {
    // what to do here?
  };
  void request() {
    http::request req2;
    req2.url = "http://example.com/";
    client.fetch(req2, [](const std::string& body, int error) {
            printf("%s\n", body.c_str());
        }
    );
  }
  http::client client;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions