Skip to content

Report connection timeout as separate event #1171

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

Merged
merged 1 commit into from
Jan 26, 2022

Conversation

gjasny
Copy link
Contributor

@gjasny gjasny commented Jan 25, 2022

No description provided.

@yhirose
Copy link
Owner

yhirose commented Jan 25, 2022

@gjasny, thanks for the pull request. Could you take a look at the problem on GitHub Actions workflow?
https://github.com/yhirose/cpp-httplib/actions/runs/1745000655

@gjasny gjasny force-pushed the connection-timeout branch from 08e983b to d862b44 Compare January 25, 2022 17:52
@gjasny gjasny force-pushed the connection-timeout branch from d862b44 to 9651238 Compare January 26, 2022 15:03
Copy link
Owner

@yhirose yhirose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could please revert back the changes of moving the following lines in test/test.cc?

ASSERT_TRUE(res);
ASSERT_EQ(200, res->status);

@gjasny gjasny force-pushed the connection-timeout branch from 9651238 to 41af41e Compare January 26, 2022 18:16
@yhirose
Copy link
Owner

yhirose commented Jan 26, 2022

According to the code added in the unit test, does this new error type occur only with AF_INET? If so, it will actually create more confusion for users using AF_UNSPEC, because they won't receive the ConnectionTimeout even if it's declared in httplib.h...

cli.set_address_family(AF_INET);

@gjasny
Copy link
Contributor Author

gjasny commented Jan 26, 2022

According to the code added in the unit test, does this new error type occur only with AF_INET? If so, it will actually create more confusion for users using AF_UNSPEC, because they won't receive the ConnectionTimeout even if it's declared in httplib.h...

cli.set_address_family(AF_INET);

It took me a while why the test was failing on Linux. What happens is:

google.com gets resolved to both: an IPv4 and an IPv6 address. The client code loops over both and for IPv4 sets the error code to "ConnectionTimeout". Then it tries IPv6 but that's not working because the test host only has an IPv4 address. Thus the error code gets overwritten and set to "Connection".

By explicitly requesting an IPv4 lookup the test avoids the second IPv6 loop and the overwriting of the error code.

If the host would have IPv6 connectivity it would also return "ConnectionTimeout" for IPv6.

@yhirose
Copy link
Owner

yhirose commented Jan 26, 2022

@gjasny, thanks for the clear explanation. I'll merge it to the master branch soon. Thanks for your contribution!

@yhirose yhirose merged commit 87e03dd into yhirose:master Jan 26, 2022
ExclusiveOrange pushed a commit to ExclusiveOrange/cpp-httplib-exor that referenced this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants