<?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>Rusty Razor Blade &#187; curl</title>
	<atom:link href="http://www.rustyrazorblade.com/category/curl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rustyrazorblade.com</link>
	<description>Tech Thoughts, Mostly on LAMP - by Jon Haddad</description>
	<lastBuildDate>Fri, 03 Feb 2012 20:03:54 +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>Setting up a Solr Index</title>
		<link>http://www.rustyrazorblade.com/2009/02/setting-up-a-solr-index/</link>
		<comments>http://www.rustyrazorblade.com/2009/02/setting-up-a-solr-index/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 00:51:16 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[curl]]></category>
		<category><![CDATA[solr]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=471</guid>
		<description><![CDATA[<p>Setting up a solr index isn&#8217;t that hard, but I found the documentation to be somewhat hard to find. It only took me a few hours from start to finish to go from download to indexing my documents, but I think it could have happened a lot faster if I had some of the below [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up a solr index isn&#8217;t that hard, but I found the documentation to be somewhat hard to find.  It only took me a few hours from start to finish to go from download to indexing my documents, but I think it could have happened a lot faster if I had some of the below information.  I&#8217;m assuming you&#8217;ve already downloaded solr and you&#8217;re now looking at a directory with a bunch of files in it.</p>
<ul>
<li>Make a copy of the example directory found in the solr directory.  To make obvious, I just named it after the site I&#8217;m working on.  </li>
<li>You&#8217;ll want to edit the solr/conf/schema.xml file found in there.  It&#8217;s actually a really good sample file to get started with, so you&#8217;ll learn a whole bunch by starting there.  <a href="http://wiki.apache.org/solr/SchemaXml">Information on the solr schema</a>.  You&#8217;ll need to modify the configuration file for solr to function correctly with your schema. </li>
<li>If you&#8217;re using a PHP and curl, and you get the error &#8220;missing content stream&#8221;, you need to make sure you set your curl header<br />
<blockquote><p>curl_setopt($c, CURLOPT_HTTPHEADER, 	array(&#8220;Content-Type: text/xml&#8221;)); 	</p></blockquote>
</li>
<li>At one point, I received the error &#8220;Unexpected EOF in prolog&#8221; &#8211; this was because I originally had a &#8220;\n&#8221; at the end of my header (see previous note).  Removing it solved my problem.</li>
<p>Here&#8217;s a <a href="http://www.xml.com/lpt/a/1668">good solr starting point</a> that covers the schema and field types.
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2009/02/setting-up-a-solr-index/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How curl_exec and urlencode killed my single sign on</title>
		<link>http://www.rustyrazorblade.com/2008/04/how-curl_exec-and-urlencode-killed-my-single-sign-on/</link>
		<comments>http://www.rustyrazorblade.com/2008/04/how-curl_exec-and-urlencode-killed-my-single-sign-on/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 18:02:04 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[curl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=117</guid>
		<description><![CDATA[<p>If you do any work with single sign on, you&#8217;ll be familiar with the concept of exchanging tokens and validating against the authentication server using that token. One of the issues I&#8217;ve just run into which resulted in a huge headache is with urlencoding the result of a curl_exec that had a line ending. It&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>If you do any work with single sign on, you&#8217;ll be familiar with the concept of exchanging tokens and validating against the authentication server using that token.  One of the issues I&#8217;ve just run into which resulted in a huge headache is with urlencoding the result of a curl_exec that had a line ending. It&#8217; easy to miss when it&#8217;s a longer string and you aren&#8217;t paying very close attention.  This is a very simple example, and it still takes a second to realize there&#8217;s an extra character at the end.</p>
<blockquote><p>php> echo urlencode(&#8220;test@str!ngw!th0u7\n&#8221;);<br />
test%40str%21ngw%21th0u7%0A<br />
php> echo urlencode(&#8220;test@str!ngw!th0u7&#8243;);<br />
test%40str%21ngw%21th0u7</p></blockquote>
<p>Basically, I&#8217;d recommend calling a trim() on any results you get back, unless you love newlines at the end for some reason.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/04/how-curl_exec-and-urlencode-killed-my-single-sign-on/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Executing multiple curl requests in parallel with PHP and curl_multi_exec</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/</link>
		<comments>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 00:17:24 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[curl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/</guid>
		<description><![CDATA[<p>Let&#8217;s get one thing out in the open. Curl is sweet. It does it&#8217;s job very well, and I&#8217;m absoutely thrilled it exists.</p> <p>If you&#8217;re using curl in your PHP app to make web requests, you&#8217;ve probably realized that by doing them one after the other, the total time of your request is the sum [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s get one thing out in the open. Curl is sweet.  It does it&#8217;s job very well, and I&#8217;m absoutely thrilled it exists.</p>
<p>If you&#8217;re using curl in your PHP app to make web requests, you&#8217;ve probably realized that by doing them one after the other, the total time of your request is the sum of all the requests put together.  That&#8217;s lame.</p>
<p>Unfortunately using the curl_multi_exec is poorly documented in the PHP manual.</p>
<p>Let&#8217;s say that your app is hitting APIs from these servers:</p>
<p>Google: .1s<br />
Microsoft: .3s<br />
rustyrazorblade.com: .5s</p>
<p>Your total time will be .9s, just for api calls.  </p>
<p>By using curl_multi_exec, you can execute those requests in parallel, and you&#8217;ll only be limited by the slowest request, which is about .5 sec to rustyrazorblade in this case, assuming your download bandwidth is not slowing you down.</p>
<p>Sample code:</p>
<pre>
$nodes = array('http://www.google.com', 'http://www.microsoft.com', 'http://www.rustyrazorblade.com');
$node_count = count($nodes);

$curl_arr = array();
$master = curl_multi_init();

for($i = 0; $i &lt; $node_count; $i++)
{
	$url =$nodes[$i];
	$curl_arr[$i] = curl_init($url);
	curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
	curl_multi_add_handle($master, $curl_arr[$i]);
}

do {
    curl_multi_exec($master,$running);
} while($running &gt; 0);

echo &quot;results: &quot;;
for($i = 0; $i &lt; $node_count; $i++)
{
	$results = curl_multi_getcontent  ( $curl_arr[$i]  );
	echo( $i . &quot;\n&quot; . $results . &quot;\n&quot;);
}
echo 'done';</pre>
<p>It&#8217;s really not documented on php.net how to use curl_multi_getcontent, so hopefully this helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/feed/</wfw:commentRss>
		<slash:comments>78</slash:comments>
		</item>
	</channel>
</rss>

