Hans Leidekker : wininet: Ignore INTERNET_FLAG_NO_CACHE_WRITE only for GET requests.
Alexandre Julliard
julliard at winehq.org
Wed Jul 31 15:31:34 CDT 2013
Module: wine
Branch: master
Commit: 5f346f63bacb9872e78eafc0a88fe4a681793c78
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5f346f63bacb9872e78eafc0a88fe4a681793c78
Author: Hans Leidekker <hans at codeweavers.com>
Date: Tue Jul 30 11:08:49 2013 +0200
wininet: Ignore INTERNET_FLAG_NO_CACHE_WRITE only for GET requests.
---
dlls/wininet/http.c | 3 +-
dlls/wininet/tests/http.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 03fbf10..c77f77a 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -4832,7 +4832,6 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
LPWSTR requestString = NULL;
INT responseLen;
BOOL loop_next;
- static const WCHAR szPost[] = { 'P','O','S','T',0 };
static const WCHAR szContentLength[] =
{ 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 };
WCHAR contentLengthStr[sizeof szContentLength/2 /* includes \r\n */ + 20 /* int */ ];
@@ -4870,7 +4869,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
static const WCHAR pragma_nocache[] = {'P','r','a','g','m','a',':',' ','n','o','-','c','a','c','h','e','\r','\n',0};
HTTP_HttpAddRequestHeadersW(request, pragma_nocache, strlenW(pragma_nocache), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
}
- if ((request->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && !strcmpW(request->verb, szPost))
+ if ((request->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && strcmpW(request->verb, szGET))
{
static const WCHAR cache_control[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l',':',
' ','n','o','-','c','a','c','h','e','\r','\n',0};
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 6022955..458554f 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2083,6 +2083,13 @@ static DWORD CALLBACK server_thread(LPVOID param)
}
if (strstr(buffer, "GET /send_from_buffer"))
send(c, send_buffer, strlen(send_buffer), 0);
+ if (strstr(buffer, "/test_cache_control_verb"))
+ {
+ if (!memcmp(buffer, "GET ", sizeof("GET ")-1) &&
+ !strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
+ else if (strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
+ send(c, notokmsg, sizeof(notokmsg)-1, 0);
+ }
if (strstr(buffer, "GET /test_premature_disconnect"))
trace("closing connection\n");
@@ -3643,6 +3650,50 @@ static void test_http_status(int port)
}
}
+static void test_cache_control_verb(int port)
+{
+ HINTERNET session, connect, request;
+ BOOL ret;
+
+ session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(session != NULL, "InternetOpen failed\n");
+
+ connect = InternetConnect(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequest(connect, "RPC_OUT_DATA", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+
+ request = HttpOpenRequest(connect, "POST", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+
+ request = HttpOpenRequest(connect, "HEAD", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+
+ request = HttpOpenRequest(connect, "GET", "/test_cache_control_verb", NULL, NULL, NULL,
+ INTERNET_FLAG_NO_CACHE_WRITE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+ ret = HttpSendRequest(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed %u\n", GetLastError());
+ test_status_code(request, 200);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+ InternetCloseHandle(session);
+}
+
static void test_http_connection(void)
{
struct server_info si;
@@ -3686,6 +3737,7 @@ static void test_http_connection(void)
test_http_status(si.port);
test_premature_disconnect(si.port);
test_connection_closing(si.port);
+ test_cache_control_verb(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
More information about the wine-cvs
mailing list