send_head: use int64_t for content_length

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
main^2
Jianhui Zhao 2021-01-21 16:02:22 +08:00
parent b2e52fe1af
commit 2f951e5166
2 changed files with 3 additions and 3 deletions

View File

@ -170,7 +170,7 @@ static void conn_send_status_line(struct uh_connection *conn, int code, const ch
conn_send(conn, extra_headers, strlen(extra_headers)); 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; struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;
@ -178,7 +178,7 @@ static void conn_send_head(struct uh_connection *conn, int code, int content_len
if (content_length < 0) if (content_length < 0)
conn_printf(conn, "%s", "Transfer-Encoding: chunked\r\n"); conn_printf(conn, "%s", "Transfer-Encoding: chunked\r\n");
else 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)) if (!http_should_keep_alive(&conni->parser))
conn_printf(conn, "%s", "Connection: close\r\n"); conn_printf(conn, "%s", "Connection: close\r\n");

View File

@ -61,7 +61,7 @@ struct uh_connection {
void (*printf)(struct uh_connection *conn, const char *format, ...) __attribute__((format(printf, 2, 3))); 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 (*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_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 (*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 (*redirect)(struct uh_connection *conn, int code, const char *location, ...) __attribute__((format(printf, 3, 4)));
void (*serve_file)(struct uh_connection *conn); void (*serve_file)(struct uh_connection *conn);