im = new Image(); im.src = my_url; The above javascript code in certain conditions fails to perform an HTTP GET when my_url is set to a domain with uppercase letters in it, as in 'http://www.apPle.com' instead of 'http://www.apple.com'. This problem occurs in the onclick handler for a link that exits the current page. **The problem DOES NOT occur when my_url is all lowercase (i.e. 'http://www.apple.com'.** I will attach a simple reduction test case to illustrate the problem.
Created attachment 10787 [details] A reduction test (in HTML) that illustrates the uppercase image request problem.
I should clarify that this occurs for any number of uppercase letters in the domain name. APPLE.com and apple.COM both fail.
rdar://4754309
I can reproduce the described behavior, and I think I have an idea about what's going on here, but I'm not sure if this is a bug. Here is the sequence of events in case 4 (uppercase domain, return false): 1) im.src is set, causing an NSURLRequest to be immediately created. 2) The "while (e.getTime()-b.getTime()<500)" loop begins, halting WebKit. NSURLConnection still works on a separate thread, but it cannot call back to WebKit yet. 3) The loop ends, and NSURLConnection finally dispatches connection:willSendRequest:redirectResponse: for the proper domain (apple.com), asking WebKit whether it's fine to proceed with this new domain. WebKit agrees to proceed. 4) NSURLConnection dispatches an HTTP request to apple.com (which actually results in one more connection:willSendRequest:redirectResponse:, because apple.com redirects to www.apple.com). However, if the onclick handler doesn't prevent leaving the page, then the request is cancelled after step 2, because the frame is destroyed. Some things we could theoretically do differently: 1) I'm not sure why NSURLConnection needs to ask after it normalizes the (case-insensitive) host name, and why this has to be done asynchronously; 2) perhaps outstanding requests shouldn't be just cancelled when destroying the frame, and we should at least let them be sent.
Safari works fine on this test: First two navigate while last two don't.