Skip to content

Refactor HTTP client #3235

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 2 commits into from
Aug 14, 2025
Merged

Refactor HTTP client #3235

merged 2 commits into from
Aug 14, 2025

Conversation

cpq
Copy link
Member

@cpq cpq commented Aug 12, 2025

No description provided.

@cpq cpq requested a review from scaprile August 12, 2025 08:22
Copy link
Collaborator

@scaprile scaprile left a comment

Choose a reason for hiding this comment

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

I can do the requested change, and cleanup files no longer in use. Let me know

@@ -49,24 +50,45 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
// Response is received. Print it
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
printf("%.*s", (int) hm->message.len, hm->message.buf);
c->is_draining = 1; // Tell mongoose to close this connection
c->is_closing = 1; // Tell mongoose to close this connection
Copy link
Collaborator

@scaprile scaprile Aug 12, 2025

Choose a reason for hiding this comment

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

Nope, c->is_draining is correct.
is_closing produces an immediate close, particularly on our built-in stack, where the closure process is not clean and any pending data could be lost.
The proper way described in our tutorials is to use is_draining
is_closing should only use internally or when deliberately closing on error.
Even though it doesn't make a difference here, we should follow our docs
Screenshot from 2025-08-12 11-11-18
2b20af3
Screenshot from 2025-08-12 11-17-34
https://mongoose.ws/documentation/#opening-and-closing-connections

@cpq
Copy link
Member Author

cpq commented Aug 14, 2025

I can do the requested change, and cleanup files no longer in use. Let me know

Yes please, take over this !

@scaprile scaprile self-requested a review August 14, 2025 13:59
@scaprile scaprile merged commit aae1a68 into master Aug 14, 2025
61 of 63 checks passed
@scaprile scaprile deleted the client branch August 14, 2025 14:00
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