mirror of
https://github.com/reactos/wine.git
synced 2024-11-26 13:10:28 +00:00
mshtml: Moved headers parsing to separated function.
This commit is contained in:
parent
6ae84b0b91
commit
8ca78fa171
@ -638,6 +638,39 @@ static void call_docview_84(HTMLDocumentObj *doc)
|
|||||||
FIXME("handle result\n");
|
FIXME("handle result\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT parse_headers(const WCHAR *headers, struct list *headers_list)
|
||||||
|
{
|
||||||
|
const WCHAR *header, *header_end, *colon, *value;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
header = headers;
|
||||||
|
while(*header) {
|
||||||
|
if(header[0] == '\r' && header[1] == '\n' && !header[2])
|
||||||
|
break;
|
||||||
|
for(colon = header; *colon && *colon != ':' && *colon != '\r'; colon++);
|
||||||
|
if(*colon != ':')
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
value = colon+1;
|
||||||
|
while(*value == ' ')
|
||||||
|
value++;
|
||||||
|
if(!*value)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
for(header_end = value+1; *header_end && *header_end != '\r'; header_end++);
|
||||||
|
|
||||||
|
hres = set_http_header(headers_list, header, colon-header, value, header_end-value);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
|
||||||
|
header = header_end;
|
||||||
|
if(header[0] == '\r' && header[1] == '\n')
|
||||||
|
header += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret,
|
static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret,
|
||||||
HGLOBAL *post_data_ret, ULONG *post_data_len_ret)
|
HGLOBAL *post_data_ret, ULONG *post_data_len_ret)
|
||||||
{
|
{
|
||||||
@ -1109,38 +1142,16 @@ static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
|
|||||||
This->nschannel->response_status = response_code;
|
This->nschannel->response_status = response_code;
|
||||||
|
|
||||||
if(response_headers) {
|
if(response_headers) {
|
||||||
const WCHAR *hdr_start, *hdr_end;
|
const WCHAR *headers;
|
||||||
|
|
||||||
hdr_start = strchrW(response_headers, '\r');
|
headers = strchrW(response_headers, '\r');
|
||||||
while(hdr_start) {
|
if(headers && headers[1] == '\n') {
|
||||||
const WCHAR *colon, *value;
|
headers += 2;
|
||||||
|
hres = parse_headers(headers, &This->nschannel->response_headers);
|
||||||
hdr_start += 2;
|
if(FAILED(hres)) {
|
||||||
hdr_end = strchrW(hdr_start, '\r');
|
WARN("parsing headers failed: %08x\n", hres);
|
||||||
if(!hdr_end) {
|
|
||||||
WARN("Header doesn't end with CRLF: %s\n", wine_dbgstr_w(hdr_start));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(hdr_end == hdr_start)
|
|
||||||
break;
|
|
||||||
|
|
||||||
for(colon = hdr_start; *colon != ':' && colon != hdr_end; ++colon);
|
|
||||||
if(*colon != ':') {
|
|
||||||
WARN("Header missing colon: %s\n", wine_dbgstr_w(hdr_start));
|
|
||||||
hdr_start = strchrW(hdr_start, '\r');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = colon+1;
|
|
||||||
while(*value == ' ')
|
|
||||||
value++;
|
|
||||||
|
|
||||||
hres = set_http_header(&This->nschannel->response_headers, hdr_start, colon-hdr_start,
|
|
||||||
value, hdr_end-value);
|
|
||||||
if(FAILED(hres))
|
|
||||||
return hres;
|
return hres;
|
||||||
|
}
|
||||||
hdr_start = strchrW(hdr_start, '\r');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user