Skip to content

Commit

Permalink
Fix Omitted Content-Length not handled anymore YAZ-894
Browse files Browse the repository at this point in the history
This issue was introduced by work in YAZ-878 YAZ Version 5.20.1.
  • Loading branch information
adamdickmeiss committed Sep 4, 2017
1 parent 01585d4 commit 47b2f50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/comstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ static int cs_complete_http(const char *buf, int len, int head_only)
head_only = 1;
else if (!memcmp(buf + j, "304", 3))
head_only = 1;
else
content_len = -1;
break;
}
}
Expand All @@ -406,7 +408,9 @@ static int cs_complete_http(const char *buf, int len, int head_only)
return cs_read_chunk(buf, i, len);
else
{ /* not chunked ; inside body */
if (len >= i + content_len)
if (content_len == -1)
return 0; /* no content length */
else if (len >= i + content_len)
{
return i + content_len;
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_comstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void tst_http_response(void)

YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 24), 19);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 24), 0);
}
{
/* no content, no headers */
Expand Down

0 comments on commit 47b2f50

Please sign in to comment.