<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BinaryKitten&#039;s Development Dropbox &#187; head</title>
	<atom:link href="http://binarykitten.com/tag/head/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.com</link>
	<description>Curently a work in progress. Please be patient</description>
	<lastBuildDate>Thu, 27 Oct 2011 21:49:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>php: processing raw Post / Get Values</title>
		<link>http://binarykitten.com/dev/php/95-php-processing-raw-post-get-values.html</link>
		<comments>http://binarykitten.com/dev/php/95-php-processing-raw-post-get-values.html#comments</comments>
		<pubDate>Wed, 21 Jan 2009 09:03:53 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[raw post]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=95</guid>
		<description><![CDATA[I just added a jquery plugin to call head requests, but because you are not doing a get or post request php won&#8217;t convert the values that are sent back to their form. To get around this we have to use the php://input stream ( is that the right word?) which is handy for a [...]]]></description>
			<content:encoded><![CDATA[<p>I just added a <a href="http://binarykitten.jkrswebsolutions.co.uk/2009/01/21/jquery-plugin-ajax-head-request/">jquery plugin</a> to call head requests, but because you are not doing a get or post request php won&#8217;t convert the values that are sent back to their form.<br />
To get around this we have to use the php://input stream ( is that the right word?) which is handy for a lot of things.</p>
<pre class="brush: php">
$data = file_get_contents(&quot;php://input&quot;);
$lines = explode(&quot;&amp;&quot;,$data);
foreach($lines as $line) {
    list($key,$value) = explode(&quot;=&quot;,$line,2);
    $_REQUEST[$key] = $value;
}
</pre>
<p>basically this grabs the data from the php://input and then splits it up into it&#8217;s component parts and then stores that within the $_REQUEST superglobal array.<br />
Why $_REQUEST  well we&#8217;re calling a head request and not a post or get request, so where else should it go.</p>
<p>The php://input is handy when doing stuff like xmlRPC or jsonRPC etc .. </p>
<p>Hopefully this will benefit someone out there</p>
<p>&lt;edit&gt;<br />
Thanks to Mortal of #php on OFTC (irc) for pointing out the unlimited explode </p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/php/95-php-processing-raw-post-get-values.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery plugin:  ajax Head Request</title>
		<link>http://binarykitten.com/dev/jq-plugins/88-jquery-plugin-ajax-head-request.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/88-jquery-plugin-ajax-head-request.html#comments</comments>
		<pubDate>Wed, 21 Jan 2009 13:34:32 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[xmlhttprequest]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=88</guid>
		<description><![CDATA[I recently looked into the head request for pulling data without much overhead. PHP can send headers out to the browser in a response.. so I looked into a way to get these headers. I came across a page that outlined using head requests via the xmlhttprequest object. I looked inside jQuery for this functionality [...]]]></description>
			<content:encoded><![CDATA[<p>I recently looked into the head request for pulling data without much overhead. PHP can send headers out to the browser in a response.. so I looked into a way to get these headers. I came across <a href="http://www.jibbering.com/2002/4/httprequest.html" target="_blank">a page</a> that outlined using head requests via the xmlhttprequest object.</p>
<p>I looked inside jQuery for this functionality and noticed it wasn&#8217;t there so I copied the $.post functionality and modified it into $.head.</p>
<p>So I present to you my Plugin for jQuery</p>
<pre class="brush: javascript">
/* jQuery.head - v1.0.3 - K Reeve aka BinaryKitten
*
*	makes a Head Request via XMLHttpRequest (ajax) and returns an object/array of headers returned from the server
*	$.head(url, [data], [callback])
*		url			The url to which to place the head request
*		data		(optional) any data you wish to pass - see $.post and $.get for more info
*		callback	(optional) Function to call when the head request is complete.
*					This function will be passed an object containing the headers with
*					the object consisting of key/value pairs where the key is the header name and the
*					value it&#039;s corresponding value
*
*	for discussion and info please visit: http://binarykitten.me.uk/jQHead
*
* ------------ Version History -----------------------------------
* v1.0.3
* 	Fixed the zero-index issue with the for loop for the headers
* v1.0.2
* 	placed the function inside an enclosure
*
* v1.0.1
* 	The 1st version - based on $.post/$.get
*/

(function ($) {
  $.extend({
	head: function( url, data, callback ) {
	  if ( $.isFunction( data ) ) {
		  callback = data;
		  data = {};
	  }

	  return $.ajax({
		type: &quot;HEAD&quot;,
		url: url,
		data: data,
		complete: function (XMLHttpRequest, textStatus) {
		  var headers = XMLHttpRequest.getAllResponseHeaders().split(&quot;\n&quot;);
		  var new_headers = {};
		  var l = headers.length;
		  for (var key=0;key&lt;l;key++) {
			  if (headers[key].length != 0) {
				  header = headers[key].split(&quot;: &quot;);
				  new_headers[header[0]] = header[1];
			  }
		  }
		  if ($.isFunction(callback)) {
			callback(new_headers);
		  }
		}
	  });
	}
  });
})(jQuery);
</pre>
<p>The function calls the passed url, passing the data and then processes the headers on completion. It takes the long text passed and splits it up into each header line and then splits it into array. The passed array is sent back to the callback function where the key of the array is the header name and the value being the header value.</p>
<p>To call our new function, we use the form just like the basic functionality of $.post and $.get:</p>
<pre class="brush: javascript">
/* $.head(&quot;url&quot;,{data},callback_function(headers) { }); */
/* Example */
$.head(&quot;index.php&quot;,{&#039;a&#039;:5,&#039;bc&#039;:&#039;help&#039;},function(headers) {
	$.each(headers,function(key,header){ console.log(key+&#039;:--:&#039;+header);});
});
</pre>
<p>This will use firebug&#8217;s console.log to output the details of each header.</p>
<p>all straight forward yes?<br />
Hopefully this will help or do something for the people out there<br />
Enjoy</p>
<p><strong>&lt; Edit &gt;</strong><br />
This has now been placed on plugins.jquery.com   ->  <a href="http://plugins.jquery.com/project/jqHead">http://plugins.jquery.com/project/jqHead</a></p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/88-jquery-plugin-ajax-head-request.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

