[PATCH 0/6] MR10223: Wininet refactors
This is the second set of patches towards the mfplat network bytestream, after !9369. Mostly preparatory work and refactors. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
From: Torge Matthies <openglfreak@googlemail.com> --- include/mfidl.idl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mfidl.idl b/include/mfidl.idl index 23bfeb532b7..e7258f26ed6 100644 --- a/include/mfidl.idl +++ b/include/mfidl.idl @@ -1628,6 +1628,7 @@ cpp_quote("EXTERN_GUID(MR_STREAM_VOLUME_SERVICE, 0xf8b5fa2f, 0x32ef, 0x46f5, 0xb cpp_quote("EXTERN_GUID(MR_AUDIO_POLICY_SERVICE, 0x911fd737, 0x6775, 0x4ab0, 0xa6, 0x14, 0x29, 0x78, 0x62, 0xfd, 0xac, 0x88);") cpp_quote("EXTERN_GUID(MF_PROPERTY_HANDLER_SERVICE, 0xa3face02, 0x32b8, 0x41dd, 0x90, 0xe7, 0x5f, 0xef, 0x7c, 0x89, 0x91, 0xb5);") cpp_quote("EXTERN_GUID(MF_WORKQUEUE_SERVICES, 0x8e37d489, 0x41e0, 0x413a, 0x90, 0x68, 0x28, 0x7c, 0x88, 0x6d, 0x8d, 0xda);") +cpp_quote("EXTERN_GUID(MFNETSOURCE_STATISTICS_SERVICE, 0x3cb1f275, 0x0505, 0x4c5d, 0xae, 0x71, 0x0a, 0x55, 0x63, 0x44, 0xef, 0xa1);") cpp_quote("EXTERN_GUID(MF_PROGRESSIVE_CODING_CONTENT, 0x8f020eea, 0x1508, 0x471f, 0x9d, 0xa6, 0x50, 0x7d, 0x7c, 0xfa, 0x40, 0xdb);") cpp_quote("EXTERN_GUID(MF_NALU_LENGTH_SET, 0xa7911d53, 0x12a4, 0x4965, 0xae, 0x70, 0x6e, 0xad, 0xd6, 0xff, 0x05, 0x51);") -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
From: Torge Matthies <openglfreak@googlemail.com> --- dlls/wininet/http.c | 75 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index e5ef9e473e9..7337b9671a3 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -266,6 +266,12 @@ static DWORD WINAPI collect_connections_proc(void *arg) FreeLibraryAndExitThread(WININET_hModule, 0); } +static void send_callback(http_request_t *req, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, + DWORD dwStatusInfoLength) +{ + INTERNET_SendCallback(&req->hdr, dwContext, dwInternetStatus, lpvStatusInfo, dwStatusInfoLength); +} + /*********************************************************************** * HTTP_GetHeader (internal) * @@ -1766,19 +1772,16 @@ static DWORD HTTP_ResolveName(http_request_t *request) if(server->addr_len) return ERROR_SUCCESS; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_RESOLVING_NAME, - server->name, - (lstrlenW(server->name)+1) * sizeof(WCHAR)); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_RESOLVING_NAME, + server->name, (lstrlenW(server->name)+1) * sizeof(WCHAR)); addr_len = sizeof(server->addr); if (!GetAddress(server->name, server->port, (SOCKADDR*)&server->addr, &addr_len, server->addr_str)) return ERROR_INTERNET_NAME_NOT_RESOLVED; server->addr_len = addr_len; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_NAME_RESOLVED, - server->addr_str, strlen(server->addr_str)+1); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_NAME_RESOLVED, + server->addr_str, strlen(server->addr_str)+1); TRACE("resolved %s to %s\n", debugstr_w(server->name), server->addr_str); return ERROR_SUCCESS; @@ -1906,13 +1909,11 @@ static void http_release_netconn(http_request_t *req, BOOL reuse) return; } - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, - INTERNET_STATUS_CLOSING_CONNECTION, 0, 0); + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_CLOSING_CONNECTION, 0, 0); close_netconn(req->netconn); - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, - INTERNET_STATUS_CONNECTION_CLOSED, 0, 0); + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_CONNECTION_CLOSED, 0, 0); } static BOOL has_token(const WCHAR *str, const WCHAR *token) @@ -3011,7 +3012,7 @@ static void send_request_complete(http_request_t *req, DWORD_PTR result, DWORD e iar.dwResult = result; iar.dwError = error; - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } @@ -3199,7 +3200,7 @@ static void async_read_file_proc(task_header_t *hdr) *task->ret_read = read; /* FIXME: We should report bytes transferred before decoding content. */ - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &read, sizeof(read)); + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &read, sizeof(read)); if(res != ERROR_SUCCESS) complete_arg = res; @@ -3312,7 +3313,7 @@ static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buf, DWORD size, DWORD if(res == ERROR_SUCCESS && read < size && (!read || !(flags & IRF_NO_WAIT)) && !end_of_read_data(req)) { LeaveCriticalSection(&req->read_section); - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); EnterCriticalSection( &req->read_section ); notify_received = TRUE; @@ -3347,7 +3348,7 @@ static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buf, DWORD size, DWORD return res; if(notify_received) - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &read, sizeof(read)); return error; } @@ -3357,14 +3358,14 @@ static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD s DWORD res; http_request_t *request = (http_request_t*)hdr; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); *written = 0; res = NETCON_send(request->netconn, buffer, size, 0, (LPINT)written); if (res == ERROR_SUCCESS) request->bytesWritten += *written; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, written, sizeof(DWORD)); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, written, sizeof(DWORD)); return res; } @@ -3400,7 +3401,7 @@ static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, if(!avail && !end_of_read_data(req)) { LeaveCriticalSection(&req->read_section); - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); EnterCriticalSection( &req->read_section ); notify_received = TRUE; @@ -3425,7 +3426,7 @@ static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, *available = avail; if(notify_received) - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, + send_callback(req, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &avail, sizeof(avail)); return error; } @@ -4278,8 +4279,8 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) return ERROR_INTERNET_INVALID_URL; } - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, - url, (url_len + 1) * sizeof(WCHAR)); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, + url, (url_len + 1) * sizeof(WCHAR)); if(urlComponents.dwHostNameLength) { BOOL custom_port = FALSE; @@ -4965,10 +4966,10 @@ static DWORD open_http_connection(http_request_t *request, BOOL *reusing) TRACE("connecting to %s, proxy %s\n", debugstr_w(request->server->name), request->proxy ? debugstr_w(request->proxy->name) : "(null)"); - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_CONNECTING_TO_SERVER, - request->server->addr_str, - strlen(request->server->addr_str)+1); + send_callback(request, request->hdr.dwContext, + INTERNET_STATUS_CONNECTING_TO_SERVER, + request->server->addr_str, + strlen(request->server->addr_str)+1); res = create_netconn(request->proxy ? request->proxy : request->server, request->security_flags, (request->hdr.ErrorMask & INTERNET_ERROR_MASK_COMBINED_SEC_CERT) != 0, @@ -4980,7 +4981,7 @@ static DWORD open_http_connection(http_request_t *request, BOOL *reusing) request->netconn = netconn; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_CONNECTED_TO_SERVER, request->server->addr_str, strlen(request->server->addr_str)+1); @@ -5167,8 +5168,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, free(request_header); TRACE("full request -> %s\n", debugstr_a(ascii_req) ); - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_SENDING_REQUEST, NULL, 0); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0); NETCON_set_timeout( request->netconn, TRUE, request->hdr.send_timeout ); res = NETCON_send(request->netconn, ascii_req, len, 0, &cnt); @@ -5184,16 +5184,15 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, request->bytesWritten = data_len; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_REQUEST_SENT, - &len, sizeof(DWORD)); + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, + &len, sizeof(DWORD)); if (bEndRequest) { DWORD dwBufferSize; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + send_callback(request, request->hdr.dwContext, + INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); if (HTTP_GetResponseHeaders(request, &responseLen)) { @@ -5210,9 +5209,9 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, continue; } - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, - INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen, - sizeof(DWORD)); + send_callback(request, request->hdr.dwContext, + INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen, + sizeof(DWORD)); http_process_keep_alive(request); HTTP_ProcessCookies(request); @@ -5405,13 +5404,13 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_ return ERROR_INTERNET_OPERATION_CANCELLED; } - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); if (HTTP_GetResponseHeaders(request, &responseLen) || !responseLen) res = ERROR_HTTP_HEADER_NOT_FOUND; - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, + send_callback(request, request->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen, sizeof(DWORD)); /* process cookies here. Is this right? */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
From: Torge Matthies <openglfreak@googlemail.com> --- dlls/wininet/http.c | 50 +++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 7337b9671a3..6cf15241f46 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2429,6 +2429,27 @@ static void commit_cache_entry(http_request_t *req) free(header); } +static void write_cache_file(http_request_t *req, const BYTE *buf, DWORD len) +{ + if(!req->hCacheFile) { + return; + } + + if(len) { + BOOL bres; + DWORD written; + + bres = WriteFile(req->hCacheFile, buf, len, &written, NULL); + if(bres) + req->cache_size += written; + else + FIXME("WriteFile failed: %lu\n", GetLastError()); + } + + if(req->data_stream->vtbl->end_of_data(req->data_stream, req)) + commit_cache_entry(req); +} + static void create_cache_entry(http_request_t *req) { WCHAR file_name[MAX_PATH+1]; @@ -2514,18 +2535,7 @@ static void create_cache_entry(http_request_t *req) return; } - if(req->read_size) { - DWORD written; - - b = WriteFile(req->hCacheFile, req->read_buf+req->read_pos, req->read_size, &written, NULL); - if(b) - req->cache_size += written; - else - FIXME("WriteFile failed: %lu\n", GetLastError()); - - if(req->data_stream->vtbl->end_of_data(req->data_stream, req)) - commit_cache_entry(req); - } + write_cache_file(req, req->read_buf+req->read_pos, req->read_size); } /* read some more data into the read buffer (the read section must be held) */ @@ -2623,21 +2633,7 @@ static DWORD read_http_stream(http_request_t *req, BYTE *buf, DWORD size, DWORD *read = 0; assert(*read <= size); - if(req->hCacheFile) { - if(*read) { - BOOL bres; - DWORD written; - - bres = WriteFile(req->hCacheFile, buf, *read, &written, NULL); - if(bres) - req->cache_size += written; - else - FIXME("WriteFile failed: %lu\n", GetLastError()); - } - - if((res == ERROR_SUCCESS && !*read) || req->data_stream->vtbl->end_of_data(req->data_stream, req)) - commit_cache_entry(req); - } + write_cache_file(req, buf, *read); return res; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
From: Torge Matthies <openglfreak@googlemail.com> --- dlls/wininet/http.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 6cf15241f46..848a3e7d5fe 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2552,7 +2552,8 @@ static DWORD read_more_data( http_request_t *req, int maxlen ) req->read_pos = 0; } - if (maxlen == -1) maxlen = sizeof(req->read_buf); + if (maxlen == -1 || maxlen > sizeof(req->read_buf)) + maxlen = sizeof(req->read_buf); res = NETCON_recv( req->netconn, req->read_buf + req->read_size, maxlen - req->read_size, TRUE, &len ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
From: Torge Matthies <openglfreak@googlemail.com> --- dlls/wininet/http.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 848a3e7d5fe..d4bd23acea6 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -335,7 +335,6 @@ static void reset_data_stream(http_request_t *req) destroy_data_stream(req->data_stream); req->data_stream = &req->netconn_stream.data_stream; req->read_pos = req->read_size = req->netconn_stream.content_read = 0; - req->content_pos = 0; req->read_gzip = FALSE; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
From: Torge Matthies <openglfreak@googlemail.com> --- dlls/wininet/http.c | 150 +++++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 70 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index d4bd23acea6..fff94c7e08a 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -5007,80 +5007,17 @@ static void set_content_length_header( http_request_t *request, DWORD len, DWORD HTTP_HttpAddRequestHeadersW( request, buf, ~0u, flags ); } -/*********************************************************************** - * HTTP_HttpSendRequestW (internal) - * - * Sends the specified request to the HTTP server - * - * RETURNS - * ERROR_SUCCESS on success - * win32 error code on failure - * - */ -static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, - DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength, - DWORD dwContentLength, BOOL bEndRequest) +static DWORD create_request(http_request_t *request, void *optional, DWORD optlen, DWORD content_length, + BOOL end_request) { BOOL redirected = FALSE, secure_proxy_connect = FALSE, loop_next; WCHAR *request_header = NULL; INT responseLen, cnt; DWORD res; - const WCHAR *appinfo_agent; - - TRACE("--> %p\n", request); - - assert(request->hdr.htype == WH_HHTTPREQ); - - /* if the verb is NULL default to GET */ - if (!request->verb) - request->verb = wcsdup(L"GET"); - - HTTP_ProcessHeader(request, L"Host", request->server->canon_host_port, - HTTP_ADDREQ_FLAG_ADD_IF_NEW | HTTP_ADDHDR_FLAG_REQ); - - if (dwContentLength || wcscmp(request->verb, L"GET")) - { - set_content_length_header(request, dwContentLength, HTTP_ADDREQ_FLAG_ADD_IF_NEW); - request->bytesToWrite = dwContentLength; - } - - appinfo_agent = request->session->appInfo->agent; - - if (appinfo_agent && *appinfo_agent) - { - WCHAR *agent_header; - int len; - - len = lstrlenW(appinfo_agent) + lstrlenW(L"User-Agent: %s\r\n"); - agent_header = malloc(len * sizeof(WCHAR)); - swprintf(agent_header, len, L"User-Agent: %s\r\n", appinfo_agent); - - HTTP_HttpAddRequestHeadersW(request, agent_header, lstrlenW(agent_header), HTTP_ADDREQ_FLAG_ADD_IF_NEW); - free(agent_header); - } - if (request->hdr.dwFlags & INTERNET_FLAG_PRAGMA_NOCACHE) - { - HTTP_HttpAddRequestHeadersW(request, L"Pragma: no-cache\r\n", - lstrlenW(L"Pragma: no-cache\r\n"), HTTP_ADDREQ_FLAG_ADD_IF_NEW); - } - if ((request->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && wcscmp(request->verb, L"GET")) - { - HTTP_HttpAddRequestHeadersW(request, L"Cache-Control: no-cache\r\n", - lstrlenW(L"Cache-Control: no-cache\r\n"), HTTP_ADDREQ_FLAG_ADD_IF_NEW); - } - - /* add the headers the caller supplied */ - if (lpszHeaders) - { - if (dwHeaderLength == 0) - dwHeaderLength = lstrlenW(lpszHeaders); - - HTTP_HttpAddRequestHeadersW(request, lpszHeaders, dwHeaderLength, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); - } do { - DWORD len, data_len = dwOptionalLength; + DWORD len, data_len = optlen; BOOL reusing_connection; char *ascii_req; @@ -5149,7 +5086,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, else { if (request->proxy && HTTP_GetCustomHeaderIndex(request, L"Content-Length", 0, TRUE) >= 0) - set_content_length_header(request, dwContentLength, HTTP_ADDREQ_FLAG_REPLACE); + set_content_length_header(request, content_length, HTTP_ADDREQ_FLAG_REPLACE); request_header = build_request_header(request, request->verb, request->path, request->version, TRUE); } @@ -5157,10 +5094,10 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, TRACE("Request header -> %s\n", debugstr_w(request_header) ); /* send the request as ASCII, tack on the optional data */ - if (!lpOptional || redirected || secure_proxy_connect) + if (!optional || redirected || secure_proxy_connect) data_len = 0; - ascii_req = build_ascii_request(request_header, lpOptional, data_len, &len); + ascii_req = build_ascii_request(request_header, optional, data_len, &len); free(request_header); TRACE("full request -> %s\n", debugstr_a(ascii_req) ); @@ -5183,7 +5120,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, send_callback(request, request->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, &len, sizeof(DWORD)); - if (bEndRequest) + if (end_request) { DWORD dwBufferSize; @@ -5338,6 +5275,79 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, while (loop_next); lend: + return res; +} + +/*********************************************************************** + * HTTP_HttpSendRequestW (internal) + * + * Sends the specified request to the HTTP server + * + * RETURNS + * ERROR_SUCCESS on success + * win32 error code on failure + * + */ +static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, + DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength, + DWORD dwContentLength, BOOL bEndRequest) +{ + DWORD res; + const WCHAR *appinfo_agent; + + TRACE("--> %p\n", request); + + assert(request->hdr.htype == WH_HHTTPREQ); + + /* if the verb is NULL default to GET */ + if (!request->verb) + request->verb = wcsdup(L"GET"); + + HTTP_ProcessHeader(request, L"Host", request->server->canon_host_port, + HTTP_ADDREQ_FLAG_ADD_IF_NEW | HTTP_ADDHDR_FLAG_REQ); + + if (dwContentLength || wcscmp(request->verb, L"GET")) + { + set_content_length_header(request, dwContentLength, HTTP_ADDREQ_FLAG_ADD_IF_NEW); + request->bytesToWrite = dwContentLength; + } + + appinfo_agent = request->session->appInfo->agent; + + if (appinfo_agent && *appinfo_agent) + { + WCHAR *agent_header; + int len; + + len = lstrlenW(appinfo_agent) + lstrlenW(L"User-Agent: %s\r\n"); + agent_header = malloc(len * sizeof(WCHAR)); + swprintf(agent_header, len, L"User-Agent: %s\r\n", appinfo_agent); + + HTTP_HttpAddRequestHeadersW(request, agent_header, lstrlenW(agent_header), HTTP_ADDREQ_FLAG_ADD_IF_NEW); + free(agent_header); + } + if (request->hdr.dwFlags & INTERNET_FLAG_PRAGMA_NOCACHE) + { + HTTP_HttpAddRequestHeadersW(request, L"Pragma: no-cache\r\n", + lstrlenW(L"Pragma: no-cache\r\n"), HTTP_ADDREQ_FLAG_ADD_IF_NEW); + } + if ((request->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && wcscmp(request->verb, L"GET")) + { + HTTP_HttpAddRequestHeadersW(request, L"Cache-Control: no-cache\r\n", + lstrlenW(L"Cache-Control: no-cache\r\n"), HTTP_ADDREQ_FLAG_ADD_IF_NEW); + } + + /* add the headers the caller supplied */ + if (lpszHeaders) + { + if (dwHeaderLength == 0) + dwHeaderLength = lstrlenW(lpszHeaders); + + HTTP_HttpAddRequestHeadersW(request, lpszHeaders, dwHeaderLength, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); + } + + res = create_request(request, lpOptional, dwOptionalLength, dwContentLength, bEndRequest); + /* TODO: send notification for P3P header */ if(res == ERROR_SUCCESS) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10223
Jacek Caban (@jacek) commented about dlls/wininet/http.c:
FreeLibraryAndExitThread(WININET_hModule, 0); }
+static void send_callback(http_request_t *req, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, + DWORD dwStatusInfoLength) +{ + INTERNET_SendCallback(&req->hdr, dwContext, dwInternetStatus, lpvStatusInfo, dwStatusInfoLength); +}
A dedicated function just to slightly simplify the first argument doesn't seem needed. Are you planning to add more code here? If it's about a better function name, we could rename `INTERNET_SendCallback` instead. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10223#note_130984
Jacek Caban (@jacek) commented about dlls/wininet/http.c:
req->read_pos = 0; }
- if (maxlen == -1) maxlen = sizeof(req->read_buf); + if (maxlen == -1 || maxlen > sizeof(req->read_buf)) + maxlen = sizeof(req->read_buf);
It seems that we're always passing -1 anyway, are you planning to change that? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10223#note_130983
On Mon Mar 2 19:13:28 2026 +0000, Jacek Caban wrote:
A dedicated function just to slightly simplify the first argument doesn't seem needed. Are you planning to add more code here? If it's about a better function name, we could rename `INTERNET_SendCallback` instead. Yes, there will be some code added here that I don't think should be copied 21 times.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10223#note_131072
On Mon Mar 2 19:13:28 2026 +0000, Jacek Caban wrote:
It seems that we're always passing -1 anyway, are you planning to change that? Hmm, originally I did use this function in more places, but it seems like that got lost at some point. If we're always passing -1 for `maxlen` anyway, should I remove the parameter from the function, or only remove this commit? I'll remove the commit for now.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10223#note_131074
participants (3)
-
Jacek Caban (@jacek) -
Reyka Matthies (@tmatthies) -
Torge Matthies