large files: convert content-length to use lws_filepos_t
This commit is contained in:
parent
37053b3a9c
commit
02638f6758
4 changed files with 16 additions and 16 deletions
|
@ -786,8 +786,8 @@ lws_client_interpret_server_handshake(struct lws *wsi)
|
|||
wsi->u.http.content_length =
|
||||
atoi(lws_hdr_simple_ptr(wsi,
|
||||
WSI_TOKEN_HTTP_CONTENT_LENGTH));
|
||||
lwsl_notice("%s: incoming content length %d\n", __func__,
|
||||
wsi->u.http.content_length);
|
||||
lwsl_notice("%s: incoming content length %llu\n", __func__,
|
||||
(unsigned long long)wsi->u.http.content_length);
|
||||
wsi->u.http.content_remain = wsi->u.http.content_length;
|
||||
} else /* can't do 1.1 without a content length or chunked */
|
||||
if (!wsi->chunked)
|
||||
|
|
|
@ -2771,7 +2771,7 @@ lws_cgi_write_split_stdout_headers(struct lws *wsi)
|
|||
wsi->cgi->l[wsi->cgi->lp] = '\0';
|
||||
switch (n) {
|
||||
case SIGNIFICANT_HDR_CONTENT_LENGTH:
|
||||
wsi->cgi->content_length = atol(wsi->cgi->l);
|
||||
wsi->cgi->content_length = atoll(wsi->cgi->l);
|
||||
break;
|
||||
case SIGNIFICANT_HDR_STATUS:
|
||||
wsi->cgi->response_code = atol(wsi->cgi->l);
|
||||
|
@ -2839,7 +2839,7 @@ lws_cgi_write_split_stdout_headers(struct lws *wsi)
|
|||
case LCHS_SINGLE_0A:
|
||||
m = wsi->hdr_state;
|
||||
if (c == '\x0a') {
|
||||
lwsl_debug("Content-Length: %ld\n", wsi->cgi->content_length);
|
||||
lwsl_debug("Content-Length: %lld\n", (unsigned long long)wsi->cgi->content_length);
|
||||
wsi->hdr_state = LHCS_RESPONSE;
|
||||
/* drop the \0xa ... finalize will add it if needed */
|
||||
break;
|
||||
|
@ -2989,8 +2989,8 @@ lws_cgi_kill_terminated(struct lws_context_per_thread *pt)
|
|||
continue;
|
||||
|
||||
if (cgi->content_length) {
|
||||
lwsl_debug("%s: wsi %p: expected content length seen: %ld\n",
|
||||
__func__, cgi->wsi, cgi->content_length_seen);
|
||||
lwsl_debug("%s: wsi %p: expected content length seen: %lld\n",
|
||||
__func__, cgi->wsi, (unsigned long long)cgi->content_length_seen);
|
||||
}
|
||||
|
||||
/* reap it */
|
||||
|
@ -3059,8 +3059,8 @@ lws_cgi_kill_terminated(struct lws_context_per_thread *pt)
|
|||
continue;
|
||||
|
||||
if (cgi->content_length)
|
||||
lwsl_debug("%s: wsi %p: expected content length seen: %ld\n",
|
||||
__func__, cgi->wsi, cgi->content_length_seen);
|
||||
lwsl_debug("%s: wsi %p: expected content length seen: %lld\n",
|
||||
__func__, cgi->wsi, (unsigned long long)cgi->content_length_seen);
|
||||
|
||||
/* reap it */
|
||||
if (waitpid(cgi->pid, &status, WNOHANG) > 0) {
|
||||
|
|
|
@ -1253,8 +1253,8 @@ struct _lws_http_mode_related {
|
|||
|
||||
enum http_version request_version;
|
||||
enum http_connection_type connection_type;
|
||||
unsigned int content_length;
|
||||
unsigned int content_remain;
|
||||
lws_filepos_t content_length;
|
||||
lws_filepos_t content_remain;
|
||||
};
|
||||
|
||||
#ifdef LWS_USE_HTTP2
|
||||
|
@ -1469,8 +1469,8 @@ struct lws_cgi {
|
|||
unsigned char *headers_pos;
|
||||
unsigned char *headers_dumped;
|
||||
unsigned char *headers_end;
|
||||
unsigned long content_length;
|
||||
unsigned long content_length_seen;
|
||||
lws_filepos_t content_length;
|
||||
lws_filepos_t content_length_seen;
|
||||
int pipe_fds[3][2];
|
||||
int match[SIGNIFICANT_HDR_COUNT];
|
||||
int pid;
|
||||
|
|
|
@ -742,7 +742,7 @@ lws_http_action(struct lws *wsi)
|
|||
lws_hdr_copy(wsi, content_length_str,
|
||||
sizeof(content_length_str) - 1,
|
||||
WSI_TOKEN_HTTP_CONTENT_LENGTH);
|
||||
wsi->u.http.content_length = atoi(content_length_str);
|
||||
wsi->u.http.content_length = atoll(content_length_str);
|
||||
}
|
||||
|
||||
if (wsi->http2_substream) {
|
||||
|
@ -2366,7 +2366,7 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,
|
|||
unsigned char *response = pt->serv_buf + LWS_PRE;
|
||||
unsigned char *p = response;
|
||||
unsigned char *end = p + context->pt_serv_buf_size - LWS_PRE;
|
||||
unsigned long computed_total_content_length;
|
||||
lws_filepos_t computed_total_content_length;
|
||||
int ret = 0, cclen = 8, n = HTTP_STATUS_OK;
|
||||
lws_fop_flags_t fflags = LWS_O_RDONLY;
|
||||
#if defined(LWS_WITH_RANGES)
|
||||
|
@ -2463,7 +2463,7 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,
|
|||
* Precompute it for the main response header
|
||||
*/
|
||||
|
||||
computed_total_content_length = (unsigned long)rp->agg +
|
||||
computed_total_content_length = (lws_filepos_t)rp->agg +
|
||||
6 /* final _lws\r\n */;
|
||||
|
||||
lws_ranges_reset(rp);
|
||||
|
@ -2484,7 +2484,7 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,
|
|||
}
|
||||
|
||||
if (ranges == 1) {
|
||||
computed_total_content_length = (unsigned long)rp->agg;
|
||||
computed_total_content_length = (lws_filepos_t)rp->agg;
|
||||
n = lws_snprintf(cache_control, sizeof(cache_control), "bytes %llu-%llu/%llu",
|
||||
rp->start, rp->end, rp->extent);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue