WebCore:
[WebKit.git] / WebCore / platform / network / cf / ResourceHandleCFNet.cpp
index dbcc9c83647d969fadbb4e6219b9254bda86628d..e348f83f56663988d359e9ada49ffb7df2f7f413 100644 (file)
@@ -116,7 +116,22 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfReque
 
     LOG(Network, "CFNet - willSendRequest(conn=%p, handle=%p) (%s)", conn, handle, handle->request().url().string().utf8().data());
 
-    ResourceRequest request(cfRequest);
+    ResourceRequest request;
+    if (cfRedirectResponse) {
+        CFHTTPMessageRef httpMessage = CFURLResponseGetHTTPResponse(cfRedirectResponse);
+        if (httpMessage && CFHTTPMessageGetResponseStatusCode(httpMessage) == 307) {
+            RetainPtr<CFStringRef> originalMethod(AdoptCF, handle->request().httpMethod().createCFString());
+            RetainPtr<CFStringRef> newMethod(AdoptCF, CFURLRequestCopyHTTPRequestMethod(cfRequest));
+            if (CFStringCompareWithOptions(originalMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(originalMethod.get())), kCFCompareCaseInsensitive)) {
+                RetainPtr<CFMutableURLRequestRef> mutableRequest(AdoptCF, CFURLRequestCreateMutableCopy(0, cfRequest));
+                CFURLRequestSetHTTPRequestMethod(mutableRequest.get(), originalMethod.get());
+                request = mutableRequest.get();
+            }
+        }
+    }
+    if (request.isNull())
+        request = cfRequest;
+    
     handle->willSendRequest(request, cfRedirectResponse);
 
     if (request.isNull())