【修复】获取头部数据时出现 OK 单独换行问题

Signed-off-by: chenyong <1521761801@qq.com>
master
chenyong 7 years ago
parent c2fc8039f0
commit 4608a22c0d

@ -545,7 +545,7 @@ int webclient_resp_status_get(struct webclient_session *session)
*
* @param session webclient session
*
* @return response content length
* @return response status code
*/
int webclient_content_length_get(struct webclient_session *session)
{
@ -689,19 +689,26 @@ int webclient_handle_response(struct webclient_session *session)
}
/* get HTTP status code */
mime_ptr = strstr(session->header->buffer, "HTTP/1.");
if (mime_ptr != RT_NULL)
mime_ptr = web_strdup(session->header->buffer);
if(mime_ptr == RT_NULL)
{
return -WEBCLIENT_NOMEM;
}
if(strstr(mime_ptr, "HTTP/1."))
{
mime_ptr += strlen("HTTP/1.x");
char *ptr = mime_ptr;
while (*mime_ptr && (*mime_ptr == ' ' || *mime_ptr == '\t'))
mime_ptr++;
ptr += strlen("HTTP/1.x");
while (*ptr && (*ptr == ' ' || *ptr == '\t'))
ptr++;
/* Terminate string after status code */
for (i = 0; ((mime_ptr[i] != ' ') && (mime_ptr[i] != '\t')); i++);
mime_ptr[i] = '\0';
for (i = 0; ((ptr[i] != ' ') && (ptr[i] != '\t')); i++);
ptr[i] = '\0';
session->resp_status = (int) strtol(mime_ptr, RT_NULL, 10);
session->resp_status = (int) strtol(ptr, RT_NULL, 10);
}
/* get content length */
@ -722,6 +729,11 @@ int webclient_handle_response(struct webclient_session *session)
session->chunk_offset = 0;
}
if (mime_ptr)
{
web_free(mime_ptr);
}
if (rc < 0)
{
return rc;

Loading…
Cancel
Save