mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
fix http incomplete send handling
Signed-off-by: David Gauchard <gauchard@laas.fr>
This commit is contained in:
parent
8294c1fa4f
commit
6c58228577
1 changed files with 6 additions and 7 deletions
13
lib/output.c
13
lib/output.c
|
@ -504,7 +504,6 @@ send_raw:
|
||||||
LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
||||||
struct libwebsocket_context *context, struct libwebsocket *wsi)
|
struct libwebsocket_context *context, struct libwebsocket *wsi)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
int n, m;
|
int n, m;
|
||||||
|
|
||||||
while (!lws_send_pipe_choked(wsi)) {
|
while (!lws_send_pipe_choked(wsi)) {
|
||||||
|
@ -516,7 +515,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
||||||
if (m < 0)
|
if (m < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wsi->u.http.filepos += n;
|
wsi->u.http.filepos += m;
|
||||||
if (m != n)
|
if (m != n)
|
||||||
/* adjust for what was not sent */
|
/* adjust for what was not sent */
|
||||||
lseek(wsi->u.http.fd, m - n, SEEK_CUR);
|
lseek(wsi->u.http.fd, m - n, SEEK_CUR);
|
||||||
|
@ -525,23 +524,23 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return -1; /* caller will close */
|
return -1; /* caller will close */
|
||||||
|
|
||||||
if (n < sizeof(context->service_buffer) ||
|
if (wsi->u.http.filepos == wsi->u.http.filelen) {
|
||||||
wsi->u.http.filepos == wsi->u.http.filelen) {
|
|
||||||
wsi->state = WSI_STATE_HTTP;
|
wsi->state = WSI_STATE_HTTP;
|
||||||
|
|
||||||
if (wsi->protocol->callback)
|
if (wsi->protocol->callback)
|
||||||
ret = user_callback_handle_rxflow(
|
/* ignore callback returned value */
|
||||||
|
user_callback_handle_rxflow(
|
||||||
wsi->protocol->callback, context, wsi,
|
wsi->protocol->callback, context, wsi,
|
||||||
LWS_CALLBACK_HTTP_FILE_COMPLETION,
|
LWS_CALLBACK_HTTP_FILE_COMPLETION,
|
||||||
wsi->user_space, NULL, 0);
|
wsi->user_space, NULL, 0);
|
||||||
return ret;
|
return 1; /* >0 indicates completed */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lwsl_notice("choked before able to send whole file (post)\n");
|
lwsl_notice("choked before able to send whole file (post)\n");
|
||||||
libwebsocket_callback_on_writable(context, wsi);
|
libwebsocket_callback_on_writable(context, wsi);
|
||||||
|
|
||||||
return ret;
|
return 0; /* indicates further processing must be done */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue