<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: XMLHttpRequest::setRequestHeader()</title>
	<atom:link href="http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/feed/" rel="self" type="application/rss+xml" />
	<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/</link>
	<description></description>
	<pubDate>Fri, 21 Nov 2008 19:02:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Andreas Amann</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-65710</link>
		<dc:creator>Andreas Amann</dc:creator>
		<pubDate>Sun, 09 Dec 2007 06:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-65710</guid>
		<description>http://bugs.webkit.org/show_bug.cgi?id=16357#c4

Seems like this is located fairly deep in the system...</description>
		<content:encoded><![CDATA[<p><a href="http://bugs.webkit.org/show_bug.cgi?id=16357#c4" rel="nofollow">http://bugs.webkit.org/show_bug.cgi?id=16357#c4</a></p>
<p>Seems like this is located fairly deep in the system&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Amann</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-65693</link>
		<dc:creator>Andreas Amann</dc:creator>
		<pubDate>Sat, 08 Dec 2007 21:22:47 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-65693</guid>
		<description>Arrgh, isn't &#60;code&#62; supposed to prevent this? Trying again…

&lt;code&gt;
&#60;html&#62;
&#60;head&#62;
	&#60;title&#62;xmlRequest Cookie Test&#60;/title&#62;
	&#60;script type="text/javascript"&#62;
		function send_xmlRequest()
		{
			var xmlRequest = new XMLHttpRequest();
			xmlRequest.onload = function() {}
			xmlRequest.open("GET","http://www.apple.com/");
			xmlRequest.setRequestHeader("Cache-Control", "no-cache");
			xmlRequest.setRequestHeader("Cookie", "");
			xmlRequest.send(null);
		}
	&#60;/script&#62;
&#60;/head&#62;
&#60;body&#62;
	&#60;ol&#62;
		&#60;li&#62;Type the following command in the Terminal&#60;br /&#62;
			&#60;tt&#62;sudo tcpdump -i en1 -c5 -A -s1500 dst host www.apple.com &#124; grep ^Cookie&#60;/tt&#62;&#60;br /&#62;
			(using &#60;tt&#62;en0&#60;/tt&#62; instead of &#60;tt&#62;en1&#60;/tt&#62; when using a wired instead of wireless connection&#60;/li&#62;
		&#60;li&#62;&#60;a href="#" onclick="send_xmlRequest();"&#62;Send new xmlRequest with empty Cookie via JavaScript&#60;/a&#62;&#60;/li&#62;
		&#60;li&#62;Check Therminal output&#60;/li&#62;
	&#60;/ol&#62;
&#60;/body&#62;
&#60;/html&#62;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Arrgh, isn&#8217;t &lt;code&gt; supposed to prevent this? Trying again…</p>
<p><code><br />
&lt;html&gt;<br />
&lt;head&gt;<br />
	&lt;title&gt;xmlRequest Cookie Test&lt;/title&gt;<br />
	&lt;script type="text/javascript"&gt;<br />
		function send_xmlRequest()<br />
		{<br />
			var xmlRequest = new XMLHttpRequest();<br />
			xmlRequest.onload = function() {}<br />
			xmlRequest.open("GET","http://www.apple.com/");<br />
			xmlRequest.setRequestHeader("Cache-Control", "no-cache");<br />
			xmlRequest.setRequestHeader("Cookie", "");<br />
			xmlRequest.send(null);<br />
		}<br />
	&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
	&lt;ol&gt;<br />
		&lt;li&gt;Type the following command in the Terminal&lt;br /&gt;<br />
			&lt;tt&gt;sudo tcpdump -i en1 -c5 -A -s1500 dst host <a href="http://www.apple.com" rel="nofollow">http://www.apple.com</a> | grep ^Cookie&lt;/tt&gt;&lt;br /&gt;<br />
			(using &lt;tt&gt;en0&lt;/tt&gt; instead of &lt;tt&gt;en1&lt;/tt&gt; when using a wired instead of wireless connection&lt;/li&gt;<br />
		&lt;li&gt;&lt;a href=&#8221;#&#8221; onclick=&#8221;send_xmlRequest();&#8221;&gt;Send new xmlRequest with empty Cookie via JavaScript&lt;/a&gt;&lt;/li&gt;<br />
		&lt;li&gt;Check Therminal output&lt;/li&gt;<br />
	&lt;/ol&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Amann</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-65692</link>
		<dc:creator>Andreas Amann</dc:creator>
		<pubDate>Sat, 08 Dec 2007 21:20:48 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-65692</guid>
		<description>The improper cookie handling is new in Safari 3 (at least in Leopard - I didn't go back to test in Tiger). It seems that XMLHttpRequest for any Webkit-powered application (this includes the Dashboard) is using Safari's cookie storage and sends the cookies in Safari. This most likely is the reason why your test works for some (it does for me in 3.0.4/10.5.1) but not for others - if Safari already has cookies for the site the XHR is going to, it the XHR will send those cookies. If no cookies are present, it seems as if the cookies specified in the setRequestHeader() are correctly used.

This is a serious issue as it breaks all cookie handling for Dashboard Widgets - I reported this to Apple as a bug back on 10/29 but it hasn't even been confirmed yet (rdar://5567386)

The following is a little test to verify what is going on:

Steps to Reproduce:
1. Visit http://www.apple.com at least once with Safari to make sure that Safari has some cookies for the site
2. Create a new HTML file with the content outlines below and open it in Safari
3. Open Terminal and execute the command specified in the first step outlined in the HTML
4. Click the link in the second step of the HTML (this will send a new xmlRequest to www.apple.com with explicitly setting the Cookie to "" (i.e., no cookie sent)
5. Check the Terminal for the output of the command - this will (in addition to summary information from the tcpdump command) show the Cookie header sent by the xmlRequest

&lt;code&gt;


	xmlRequest Cookie Test
	
		function send_xmlRequest()
		{
			var xmlRequest = new XMLHttpRequest();
			xmlRequest.onload = function() {}
			xmlRequest.open("GET","http://www.apple.com/");
			xmlRequest.setRequestHeader("Cache-Control", "no-cache");
			xmlRequest.setRequestHeader("Cookie", "");
			xmlRequest.send(null);
		}
	


	
		Type the following command in the Terminal
			sudo tcpdump -i en1 -c5 -A -s1500 dst host www.apple.com &#124; grep ^Cookie
			(using en0 instead of en1 when using a wired instead of wireless connection
		&lt;a href="#" rel="nofollow"&gt;Send new xmlRequest with empty Cookie via JavaScript&lt;/a&gt;
		Check Therminal output
	


&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>The improper cookie handling is new in Safari 3 (at least in Leopard - I didn&#8217;t go back to test in Tiger). It seems that XMLHttpRequest for any Webkit-powered application (this includes the Dashboard) is using Safari&#8217;s cookie storage and sends the cookies in Safari. This most likely is the reason why your test works for some (it does for me in 3.0.4/10.5.1) but not for others - if Safari already has cookies for the site the XHR is going to, it the XHR will send those cookies. If no cookies are present, it seems as if the cookies specified in the setRequestHeader() are correctly used.</p>
<p>This is a serious issue as it breaks all cookie handling for Dashboard Widgets - I reported this to Apple as a bug back on 10/29 but it hasn&#8217;t even been confirmed yet (rdar://5567386)</p>
<p>The following is a little test to verify what is going on:</p>
<p>Steps to Reproduce:<br />
1. Visit <a href="http://www.apple.com" rel="nofollow">http://www.apple.com</a> at least once with Safari to make sure that Safari has some cookies for the site<br />
2. Create a new HTML file with the content outlines below and open it in Safari<br />
3. Open Terminal and execute the command specified in the first step outlined in the HTML<br />
4. Click the link in the second step of the HTML (this will send a new xmlRequest to <a href="http://www.apple.com" rel="nofollow">http://www.apple.com</a> with explicitly setting the Cookie to &#8220;&#8221; (i.e., no cookie sent)<br />
5. Check the Terminal for the output of the command - this will (in addition to summary information from the tcpdump command) show the Cookie header sent by the xmlRequest</p>
<p><code></p>
<p>	xmlRequest Cookie Test</p>
<p>		function send_xmlRequest()<br />
		{<br />
			var xmlRequest = new XMLHttpRequest();<br />
			xmlRequest.onload = function() {}<br />
			xmlRequest.open("GET","http://www.apple.com/");<br />
			xmlRequest.setRequestHeader("Cache-Control", "no-cache");<br />
			xmlRequest.setRequestHeader("Cookie", "");<br />
			xmlRequest.send(null);<br />
		}</p>
<p>		Type the following command in the Terminal<br />
			sudo tcpdump -i en1 -c5 -A -s1500 dst host <a href="http://www.apple.com" rel="nofollow">http://www.apple.com</a> | grep ^Cookie<br />
			(using en0 instead of en1 when using a wired instead of wireless connection<br />
		<a href="#" rel="nofollow">Send new xmlRequest with empty Cookie via JavaScript</a><br />
		Check Therminal output</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63584</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Tue, 20 Nov 2007 05:52:53 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63584</guid>
		<description>Frank...not that I'm aware of. I still don't see the cookie in 3.0.4. So...odd.</description>
		<content:encoded><![CDATA[<p>Frank&#8230;not that I&#8217;m aware of. I still don&#8217;t see the cookie in 3.0.4. So&#8230;odd.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Manno</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63463</link>
		<dc:creator>Frank Manno</dc:creator>
		<pubDate>Mon, 19 Nov 2007 13:57:18 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63463</guid>
		<description>Weird... I see it on Safari 2.0.4 (419.3):

Cookies
thisisa=test

Has a workaround been found, Ryan?</description>
		<content:encoded><![CDATA[<p>Weird&#8230; I see it on Safari 2.0.4 (419.3):</p>
<p>Cookies<br />
thisisa=test</p>
<p>Has a workaround been found, Ryan?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63278</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Sun, 18 Nov 2007 06:08:20 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63278</guid>
		<description>Sam, I'm running 3.0.4 on Leopard and I never see my "thisisa" cookie. What version are you running?

Steve, yeah...I've seen that bug called out before. Unfortunately, since I'm using the YUI connection manager, I'm not actually controlling the call to setRequestHeader().</description>
		<content:encoded><![CDATA[<p>Sam, I&#8217;m running 3.0.4 on Leopard and I never see my &#8220;thisisa&#8221; cookie. What version are you running?</p>
<p>Steve, yeah&#8230;I&#8217;ve seen that bug called out before. Unfortunately, since I&#8217;m using the YUI connection manager, I&#8217;m not actually controlling the call to setRequestHeader().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63235</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Sat, 17 Nov 2007 20:50:44 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63235</guid>
		<description>You need to add it twice via setHeader in IE: http://support.microsoft.com/?id=234486

Or, just use setCookie() instead.</description>
		<content:encoded><![CDATA[<p>You need to add it twice via setHeader in IE: <a href="http://support.microsoft.com/?id=234486" rel="nofollow">http://support.microsoft.com/?id=234486</a></p>
<p>Or, just use setCookie() instead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Pullara</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63216</link>
		<dc:creator>Sam Pullara</dc:creator>
		<pubDate>Sat, 17 Nov 2007 17:30:20 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63216</guid>
		<description>When I refreshed it though, I see Google Analytics cookies :)</description>
		<content:encoded><![CDATA[<p>When I refreshed it though, I see Google Analytics cookies <img src='http://unclehulka.com/ryan/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Pullara</title>
		<link>http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63215</link>
		<dc:creator>Sam Pullara</dc:creator>
		<pubDate>Sat, 17 Nov 2007 17:29:28 +0000</pubDate>
		<guid isPermaLink="false">http://unclehulka.com/ryan/blog/archives/2007/11/17/xmlhttprequestsetrequestheader/#comment-63215</guid>
		<description>Your test works in Safari 3.0 on Leopard as well.</description>
		<content:encoded><![CDATA[<p>Your test works in Safari 3.0 on Leopard as well.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
