forked from latticeware/Cytoplasm
Fix leak in HttpClient.
This commit is contained in:
parent
814bef932f
commit
5975222246
1 changed files with 12 additions and 8 deletions
|
@ -186,7 +186,7 @@ HttpRequestSendHeaders(HttpClientContext * context)
|
||||||
HttpStatus
|
HttpStatus
|
||||||
HttpRequestSend(HttpClientContext * context)
|
HttpRequestSend(HttpClientContext * context)
|
||||||
{
|
{
|
||||||
HttpStatus status;
|
HttpStatus status = HTTP_STATUS_UNKNOWN;
|
||||||
|
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
ssize_t lineLen;
|
ssize_t lineLen;
|
||||||
|
@ -195,7 +195,7 @@ HttpRequestSend(HttpClientContext * context)
|
||||||
|
|
||||||
if (!context)
|
if (!context)
|
||||||
{
|
{
|
||||||
return 0;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamFlush(context->stream);
|
StreamFlush(context->stream);
|
||||||
|
@ -210,19 +210,19 @@ HttpRequestSend(HttpClientContext * context)
|
||||||
|
|
||||||
if (lineLen == -1)
|
if (lineLen == -1)
|
||||||
{
|
{
|
||||||
return 0;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line must contain at least "HTTP/x.x xxx" */
|
/* Line must contain at least "HTTP/x.x xxx" */
|
||||||
if (lineLen < 12)
|
if (lineLen < 12)
|
||||||
{
|
{
|
||||||
return 0;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(strncmp(line, "HTTP/1.0", 8) == 0 ||
|
if (!(strncmp(line, "HTTP/1.0", 8) == 0 ||
|
||||||
strncmp(line, "HTTP/1.1", 8) == 0))
|
strncmp(line, "HTTP/1.1", 8) == 0))
|
||||||
{
|
{
|
||||||
return 0;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = line + 9;
|
tmp = line + 9;
|
||||||
|
@ -234,22 +234,26 @@ HttpRequestSend(HttpClientContext * context)
|
||||||
|
|
||||||
if (!*tmp)
|
if (!*tmp)
|
||||||
{
|
{
|
||||||
return 0;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = atoi(tmp);
|
status = atoi(tmp);
|
||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
return 0;
|
status = HTTP_STATUS_UNKNOWN;
|
||||||
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
context->responseHeaders = HttpParseHeaders(context->stream);
|
context->responseHeaders = HttpParseHeaders(context->stream);
|
||||||
if (!context->responseHeaders)
|
if (!context->responseHeaders)
|
||||||
{
|
{
|
||||||
return 0;
|
status = HTTP_STATUS_UNKNOWN;
|
||||||
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finish:
|
||||||
|
Free(line);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue