components/webclient/src/webclient.c
const char *webclient_header_fields_get(struct webclient_session *session, const char *fields)
{
    char *resp_buf = NULL;
    size_t resp_buf_len = 0;

    if (!session || !session->header->buffer)
    {
        return WEBCLIENT_ERROR;
    }

    resp_buf = session->header->buffer;
    while (resp_buf_len < session->header->length)
    {
        if (strstr(resp_buf, fields))
        {
            char *mime_ptr = NULL;

            /* jump space */
            mime_ptr = strstr(resp_buf, ":");
            if (mime_ptr != NULL)
            {
                mime_ptr += 1;

                while (*mime_ptr && (*mime_ptr == ' ' || *mime_ptr == '\t'))
                    mime_ptr++;

                return mime_ptr;
            }
        }

        if (*resp_buf == '\0')
            break;

        resp_buf += strlen(resp_buf) + 1;
        resp_buf_len += strlen(resp_buf) + 1;
    }

    return NULL;
}
/**
 * get fields information from request/response header data.
 *
 * @param session webclient session
 * @param fields fields keyword
 *
 * @return = NULL: get fields data failed
 *        != NULL: success get fields data
 */
get fields information from request/response header data.
@param session webclient session
@param fields fields keyword

@return = NULL: get fields data failed
!= NULL: success get fields data
get fields information from request / response header data . @param session webclient session @param fields fields keyword @return = NULL : get fields data failed ! = NULL : success get fields data
const char *webclient_header_fields_get(struct webclient_session *session, const char *fields)
{
    char *resp_buf = NULL;
    size_t resp_buf_len = 0;
    if (!session || !session->header->buffer)
    {
        return WEBCLIENT_ERROR;
    }
    resp_buf = session->header->buffer;
    while (resp_buf_len < session->header->length)
    {
        if (strstr(resp_buf, fields))
        {
            char *mime_ptr = NULL;
            mime_ptr = strstr(resp_buf, ":");
            if (mime_ptr != NULL)
            {
                mime_ptr += 1;
                while (*mime_ptr && (*mime_ptr == ' ' || *mime_ptr == '\t'))
                    mime_ptr++;
                return mime_ptr;
            }
        }
        if (*resp_buf == '\0')
            break;
        resp_buf += strlen(resp_buf) + 1;
        resp_buf_len += strlen(resp_buf) + 1;
    }
    return NULL;
}
const char * webclient_header_fields_get ( struct webclient_session * session , const char * fields ) { char * resp_buf = NULL ; size_t resp_buf_len = 0 ; if ( ! session || ! session -> header -> buffer ) { return WEBCLIENT_ERROR ; } resp_buf = session -> header -> buffer ; while ( resp_buf_len < session -> header -> length ) { if ( strstr ( resp_buf , fields ) ) { char * mime_ptr = NULL ; mime_ptr = strstr ( resp_buf , " " ) ; if ( mime_ptr != NULL ) { mime_ptr += 1 ; while ( * mime_ptr && ( * mime_ptr == ' ' || * mime_ptr == ' \t ' ) ) mime_ptr ++ ; return mime_ptr ; } } if ( * resp_buf == ' \0 ' ) break ; resp_buf += strlen ( resp_buf ) + 1 ; resp_buf_len += strlen ( resp_buf ) + 1 ; } return NULL ; }
get fields information from request/response header data.
get fields information from request / response header data .
/* jump space */