Commit d4cff191 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Improve header parsing.

parent 9d16a422
...@@ -44,47 +44,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); ...@@ -44,47 +44,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
static int fix_headers(char *buf, DWORD post_len) static int fix_headers(char *buf, DWORD post_len)
{ {
char *ptr = NULL; char *ptr = buf, *ptr2;
if(!strncasecmp(USER_AGENT, buf, sizeof(USER_AGENT)-1)) {
ptr = buf;
}else {
ptr = strstr(buf, "\r\n" USER_AGENT);
if(ptr)
ptr += 2;
}
if(ptr) { while(*ptr && (ptr[0] != '\r' || ptr[1] != '\n')) {
const char *ptr2; for(ptr2=ptr+1; *ptr2 && (ptr2[0] != '\r' || ptr2[1] != '\n'); ptr2++);
FIXME("Ignoring User-Agent header\n"); if(*ptr2)
ptr2 += 2;
ptr2 = strstr(ptr, "\r\n"); if(!strncasecmp(ptr, USER_AGENT, sizeof(USER_AGENT)-1)) {
if(ptr2) FIXME("Ignoring User-Agent header\n");
memmove(ptr, ptr2, strlen(ptr2)+1); memmove(ptr, ptr2, strlen(ptr2)+1);
} }else if(!post_len && !strncasecmp(ptr, CONTENT_TYPE, sizeof(CONTENT_TYPE)-1)) {
if(!post_len) {
if(!strncasecmp(CONTENT_TYPE, buf, sizeof(CONTENT_TYPE)-1)) {
ptr = buf;
}else {
ptr = strstr(buf, "\r\n" CONTENT_TYPE);
if(ptr)
ptr += 2;
}
if(ptr) {
const char *ptr2;
TRACE("Ignoring Content-Type header\n"); TRACE("Ignoring Content-Type header\n");
memmove(ptr, ptr2, strlen(ptr2)+1);
ptr2 = strstr(ptr, "\r\n"); }else {
if(ptr2) ptr = ptr2;
memmove(ptr, ptr2, strlen(ptr2)+1);
} }
} }
return strlen(buf); *ptr = 0;
return ptr-buf;
} }
static nsIInputStream *get_post_data_stream(IBindCtx *bctx) static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
...@@ -159,18 +139,16 @@ static nsIInputStream *get_post_data_stream(IBindCtx *bctx) ...@@ -159,18 +139,16 @@ static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
} }
if(post_len) { if(post_len) {
if(len >= 4 && !strcmp(data+len-4, "\r\n\r\n"))
len -= 2;
sprintf(data+len, content_length, post_len); sprintf(data+len, content_length, post_len);
len = strlen(data); len += strlen(data+len);
memcpy(data+len, bindinfo.stgmedData.u.hGlobal, post_len); memcpy(data+len, bindinfo.stgmedData.u.hGlobal, post_len);
} }
TRACE("data = %s\n", debugstr_an(data, len+post_len)); TRACE("data = %s\n", debugstr_an(data, len+post_len));
ret = create_nsstream(data, len+post_len); if(len)
ret = create_nsstream(data, len+post_len);
} }
CoTaskMemFree(headers); CoTaskMemFree(headers);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment