mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:31:41 +03:00
parent
bcb02fe526
commit
def4d8986e
1 changed files with 18 additions and 10 deletions
28
lib/http.c
28
lib/http.c
|
|
@ -166,17 +166,29 @@ char *Curl_checkProxyheaders(struct Curl_easy *data,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* If the header has a value, this function returns TRUE and the value is in
|
||||||
|
'outp' with blanks trimmed off.
|
||||||
|
*/
|
||||||
|
static bool header_has_value(const char **headerp, struct Curl_str *outp)
|
||||||
|
{
|
||||||
|
bool value = !curlx_str_cspn(headerp, outp, ";:") &&
|
||||||
|
(!curlx_str_single(headerp, ':') || !curlx_str_single(headerp, ';'));
|
||||||
|
|
||||||
|
if(value) {
|
||||||
|
curlx_str_untilnl(headerp, outp, MAX_HTTP_RESP_HEADER_SIZE);
|
||||||
|
curlx_str_trimblanks(outp);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static bool http_header_is_empty(const char *header)
|
static bool http_header_is_empty(const char *header)
|
||||||
{
|
{
|
||||||
struct Curl_str out;
|
struct Curl_str out;
|
||||||
|
|
||||||
if(!curlx_str_cspn(&header, &out, ";:") &&
|
if(header_has_value(&header, &out)) {
|
||||||
(!curlx_str_single(&header, ':') || !curlx_str_single(&header, ';'))) {
|
|
||||||
curlx_str_untilnl(&header, &out, MAX_HTTP_RESP_HEADER_SIZE);
|
|
||||||
curlx_str_trimblanks(&out);
|
|
||||||
return curlx_strlen(&out) == 0;
|
return curlx_strlen(&out) == 0;
|
||||||
}
|
}
|
||||||
return TRUE; /* invalid head format, treat as empty */
|
return TRUE; /* invalid header format, treat as empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -192,11 +204,7 @@ static CURLcode copy_custom_value(const char *header, char **valp)
|
||||||
struct Curl_str out;
|
struct Curl_str out;
|
||||||
|
|
||||||
/* find the end of the header name */
|
/* find the end of the header name */
|
||||||
if(!curlx_str_cspn(&header, &out, ";:") &&
|
if(header_has_value(&header, &out)) {
|
||||||
(!curlx_str_single(&header, ':') || !curlx_str_single(&header, ';'))) {
|
|
||||||
curlx_str_untilnl(&header, &out, MAX_HTTP_RESP_HEADER_SIZE);
|
|
||||||
curlx_str_trimblanks(&out);
|
|
||||||
|
|
||||||
*valp = curlx_memdup0(curlx_str(&out), curlx_strlen(&out));
|
*valp = curlx_memdup0(curlx_str(&out), curlx_strlen(&out));
|
||||||
if(*valp)
|
if(*valp)
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue