wininet: Get rid of rawHeaders field in request_t structure.

This commit is contained in:
Piotr Caban 2013-04-30 17:00:18 +02:00 committed by Alexandre Julliard
parent 566b14479c
commit 422fb313d3
2 changed files with 10 additions and 62 deletions

View File

@ -701,7 +701,7 @@ static WCHAR* build_response_header(http_request_t *request, BOOL use_cr)
if(!req) if(!req)
return NULL; return NULL;
if(request->rawHeaders) if (request->status_code)
{ {
req[n++] = request->version; req[n++] = request->version;
sprintfW(buf, status_fmt, request->status_code); sprintfW(buf, status_fmt, request->status_code);
@ -1847,7 +1847,6 @@ static void HTTPREQ_Destroy(object_header_t *hdr)
heap_free(request->path); heap_free(request->path);
heap_free(request->verb); heap_free(request->verb);
heap_free(request->rawHeaders);
heap_free(request->version); heap_free(request->version);
heap_free(request->statusText); heap_free(request->statusText);
@ -2179,7 +2178,7 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe
if(req->proxy) if(req->proxy)
flags |= INTERNET_REQFLAG_VIA_PROXY; flags |= INTERNET_REQFLAG_VIA_PROXY;
if(!req->rawHeaders) if(!req->status_code)
flags |= INTERNET_REQFLAG_NO_HEADERS; flags |= INTERNET_REQFLAG_NO_HEADERS;
TRACE("INTERNET_OPTION_REQUEST_FLAGS returning %x\n", flags); TRACE("INTERNET_OPTION_REQUEST_FLAGS returning %x\n", flags);
@ -5742,10 +5741,7 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
INT rc = 0; INT rc = 0;
char bufferA[MAX_REPLY_LEN]; char bufferA[MAX_REPLY_LEN];
LPWSTR status_code = NULL, status_text = NULL; LPWSTR status_code = NULL, status_text = NULL;
DWORD res = ERROR_HTTP_INVALID_SERVER_RESPONSE, cchMaxRawHeaders = 1024; DWORD res = ERROR_HTTP_INVALID_SERVER_RESPONSE;
LPWSTR lpszRawHeaders = NULL;
LPWSTR temp;
DWORD cchRawHeaders = 0;
BOOL codeHundred = FALSE; BOOL codeHundred = FALSE;
TRACE("-->\n"); TRACE("-->\n");
@ -5802,9 +5798,6 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
request->version = heap_strdupW(g_szHttp1_0); request->version = heap_strdupW(g_szHttp1_0);
request->statusText = heap_strdupW(szOK); request->statusText = heap_strdupW(szOK);
heap_free(request->rawHeaders);
request->rawHeaders = heap_strdupW(szDefaultHeader);
goto lend; goto lend;
} }
} while (codeHundred); } while (codeHundred);
@ -5823,21 +5816,6 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
*(status_code-1) = ' '; *(status_code-1) = ' ';
*(status_text-1) = ' '; *(status_text-1) = ' ';
/* regenerate raw headers */
lpszRawHeaders = heap_alloc((cchMaxRawHeaders + 1) * sizeof(WCHAR));
if (!lpszRawHeaders) goto lend;
while (cchRawHeaders + buflen + strlenW(szCrLf) > cchMaxRawHeaders)
cchMaxRawHeaders *= 2;
temp = heap_realloc(lpszRawHeaders, (cchMaxRawHeaders+1)*sizeof(WCHAR));
if (temp == NULL) goto lend;
lpszRawHeaders = temp;
memcpy(lpszRawHeaders+cchRawHeaders, buffer, (buflen-1)*sizeof(WCHAR));
cchRawHeaders += (buflen-1);
memcpy(lpszRawHeaders+cchRawHeaders, szCrLf, sizeof(szCrLf));
cchRawHeaders += sizeof(szCrLf)/sizeof(szCrLf[0])-1;
lpszRawHeaders[cchRawHeaders] = '\0';
/* Parse each response line */ /* Parse each response line */
do do
{ {
@ -5854,20 +5832,8 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
pFieldAndValue = HTTP_InterpretHttpHeader(buffer); pFieldAndValue = HTTP_InterpretHttpHeader(buffer);
if (pFieldAndValue) if (pFieldAndValue)
{ {
while (cchRawHeaders + buflen + strlenW(szCrLf) > cchMaxRawHeaders)
cchMaxRawHeaders *= 2;
temp = heap_realloc(lpszRawHeaders, (cchMaxRawHeaders+1)*sizeof(WCHAR));
if (temp == NULL) goto lend;
lpszRawHeaders = temp;
memcpy(lpszRawHeaders+cchRawHeaders, buffer, (buflen-1)*sizeof(WCHAR));
cchRawHeaders += (buflen-1);
memcpy(lpszRawHeaders+cchRawHeaders, szCrLf, sizeof(szCrLf));
cchRawHeaders += sizeof(szCrLf)/sizeof(szCrLf[0])-1;
lpszRawHeaders[cchRawHeaders] = '\0';
HTTP_ProcessHeader(request, pFieldAndValue[0], pFieldAndValue[1], HTTP_ProcessHeader(request, pFieldAndValue[0], pFieldAndValue[1],
HTTP_ADDREQ_FLAG_ADD ); HTTP_ADDREQ_FLAG_ADD );
HTTP_FreeTokens(pFieldAndValue); HTTP_FreeTokens(pFieldAndValue);
} }
} }
@ -5879,27 +5845,10 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
} }
}while(1); }while(1);
/* make sure the response header is terminated with an empty line. Some apps really
truly care about that empty line being there for some reason. Just add it to the
header. */
if (cchRawHeaders + strlenW(szCrLf) > cchMaxRawHeaders)
{
cchMaxRawHeaders = cchRawHeaders + strlenW(szCrLf);
temp = heap_realloc(lpszRawHeaders, (cchMaxRawHeaders + 1) * sizeof(WCHAR));
if (temp == NULL) goto lend;
lpszRawHeaders = temp;
}
memcpy(&lpszRawHeaders[cchRawHeaders], szCrLf, sizeof(szCrLf));
heap_free(request->rawHeaders);
request->rawHeaders = lpszRawHeaders;
TRACE("raw headers: %s\n", debugstr_w(lpszRawHeaders));
res = ERROR_SUCCESS; res = ERROR_SUCCESS;
lend: lend:
if (res) heap_free(lpszRawHeaders);
*len = rc; *len = rc;
TRACE("<--\n"); TRACE("<--\n");
return res; return res;

View File

@ -343,7 +343,6 @@ typedef struct
server_t *proxy; server_t *proxy;
LPWSTR path; LPWSTR path;
LPWSTR verb; LPWSTR verb;
LPWSTR rawHeaders;
netconn_t *netconn; netconn_t *netconn;
DWORD security_flags; DWORD security_flags;
DWORD connect_timeout; DWORD connect_timeout;