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

civetweb: extend API to allow enforced connection close. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/civetweb.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ CIVETWEB_API void mg_send_file(struct mg_connection *conn, const char *path);
> 0 number of bytes read into the buffer. */
CIVETWEB_API int mg_read(struct mg_connection *, void *buf, size_t len);

/* Enforce closing socket after serving current request even if connection
* is in keep-alive mode.
* Useful when serving content without specified length while keep-alive mode
* should be generally preserved. */
CIVETWEB_API void mg_enforce_close(struct mg_connection *conn);

/* Get the value of particular HTTP header.

Expand Down
5 changes: 5 additions & 0 deletions src/civetweb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,11 @@ int mg_vprintf(struct mg_connection *conn, const char *fmt, va_list ap)
return len;
}

void mg_enforce_close(struct mg_connection *conn)
{
conn->must_close = 1;
}

int mg_printf(struct mg_connection *conn, const char *fmt, ...)
{
va_list ap;
Expand Down