Skip to content

Commit

Permalink
send_head: use int64_t for content_length
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Jan 21, 2021
1 parent b2e52fe commit 2f951e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ static void conn_send_status_line(struct uh_connection *conn, int code, const ch
conn_send(conn, extra_headers, strlen(extra_headers));
}

static void conn_send_head(struct uh_connection *conn, int code, int content_length, const char *extra_headers)
static void conn_send_head(struct uh_connection *conn, int code, int64_t content_length, const char *extra_headers)
{
struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;

conn_send_status_line(conn, code, extra_headers);
if (content_length < 0)
conn_printf(conn, "%s", "Transfer-Encoding: chunked\r\n");
else
conn_printf(conn, "Content-Length: %d\r\n", content_length);
conn_printf(conn, "Content-Length: %" PRIu64 "\r\n", content_length);

if (!http_should_keep_alive(&conni->parser))
conn_printf(conn, "%s", "Connection: close\r\n");
Expand Down
2 changes: 1 addition & 1 deletion src/uhttpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct uh_connection {
void (*printf)(struct uh_connection *conn, const char *format, ...) __attribute__((format(printf, 2, 3)));
void (*vprintf)(struct uh_connection *conn, const char *format, va_list arg);
void (*send_status_line)(struct uh_connection *conn, int code, const char *extra_headers);
void (*send_head)(struct uh_connection *conn, int code, int content_length, const char *extra_headers);
void (*send_head)(struct uh_connection *conn, int code, int64_t content_length, const char *extra_headers);
void (*error)(struct uh_connection *conn, int code, const char *reason);
void (*redirect)(struct uh_connection *conn, int code, const char *location, ...) __attribute__((format(printf, 3, 4)));
void (*serve_file)(struct uh_connection *conn);
Expand Down

0 comments on commit 2f951e5

Please sign in to comment.