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

cpr::MultiPerform not using the logging interceptor #862

Closed
GloriousWizard opened this issue Dec 14, 2022 · 2 comments · Fixed by #863
Closed

cpr::MultiPerform not using the logging interceptor #862

GloriousWizard opened this issue Dec 14, 2022 · 2 comments · Fixed by #863

Comments

@GloriousWizard
Copy link

GloriousWizard commented Dec 14, 2022

Description

Adding a session with an interceptor to a cpr::MultiPerform does not print out any information to the command line.

Example/How to Reproduce

cpr::Response LoggingInterceptor::intercept(cpr::Session& session)
{
    // Log the request URL
    std::cout << "Request url:  " << session.GetFullRequestUrl() << '\n';

    // Proceed the request and save the response
    cpr::Response response = proceed(session);

    // Log response status code
    std::cout << "Response status code:  " << response.status_code << '\n';

    // Return the stored response
    return response;
}

int main()
{
    cpr::MultiPerform multiPerform;
    std::shared_ptr<cpr::Session> session = std::make_shared<cpr::Session>();

    session->SetUrl("duckduckgo.com");
    session->AddInterceptor(std::make_shared<LoggingInterceptor>());

    multiPerform1.AddSession(session);
    std::vector<cpr::Response> responses = multiPerform.Get();
}

Possible Fix

No response

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

  • OS: Nobara
  • Version: 36
  • Using commit 1986262ba4e0cb052161e9e7919aef5ef08217f0
@COM8
Copy link
Member

COM8 commented Dec 15, 2022

Thank you very much for reporting this!
This is an oversight from our side.

I created a PR (#863) with a fix for it. Could you please try, if it fulfils your needs?

@GloriousWizard
Copy link
Author

It solves my issue. You can merge the PR.

@COM8 COM8 closed this as completed in #863 Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants