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

Session with different urls #1058

Closed
a412h opened this issue May 30, 2024 · 2 comments
Closed

Session with different urls #1058

a412h opened this issue May 30, 2024 · 2 comments
Assignees

Comments

@a412h
Copy link

a412h commented May 30, 2024

This is not a bug of the library, only a question.
Let us say that I have to maintain a connection to two different urls (same base url, but two different endpoints) with a Session object. What is the recommended approach ?
Should I instantiate one session object, and change the url in the session object each time before a message is sent ? For example, with two different urls:

cpr::Session session;

session.SetUrl(cpr::Url{url1});
cpr::Response r1 = session.Post();

session.SetUrl(cpr::Url{url2});
cpr::Response r2 = session.Post();

Is that efficient ? What would be the recommended approach ?

@COM8
Copy link
Member

COM8 commented May 31, 2024

Go with two sessions since that way you keep the session stats. Else every request would initiate a new SSL handshake, which is slow.

@COM8 COM8 self-assigned this May 31, 2024
@a412h
Copy link
Author

a412h commented May 31, 2024

Thank you for the prompt and clear response.

@a412h a412h closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants