Skip to content

Commit

Permalink
conn_get_header: Fix bug
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Jul 2, 2020
1 parent 97ab987 commit e9666e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static const char *conn_get_query(struct uh_connection *conn)
static const char *conn_get_header(struct uh_connection *conn, const char *name)
{
struct uh_request *req = &conn->req;
int name_len = strlen(name);
int i, j;

for (i = 0; i < UHTTPD_MAX_HEADER_NUM; i++) {
Expand All @@ -217,7 +218,7 @@ static const char *conn_get_header(struct uh_connection *conn, const char *name)
for (j = 0; j < UHTTPD_MAX_HEADER_NUM; j++) {
if (req->headers_info[j].name_offset > 0) {
const char *p = O2D(conn, req->headers_info[j].name_offset);
if (!strncmp(p, name, req->headers_info[j].name_len)) {
if (name_len == req->headers_info[j].name_len && !strncmp(p, name, req->headers_info[j].name_len)) {
req->headers[i].name = strndup(p, req->headers_info[j].name_len);
req->headers[i].value = strndup(O2D(conn, req->headers_info[j].value_offset), req->headers_info[j].value_len);
req->headers_info[j].name_len = 0;
Expand Down

0 comments on commit e9666e8

Please sign in to comment.