<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post/2656/</link>
<title><![CDATA[curl之CURLOPT_HTTPHEADER设置header头，还能实现不用设置Hosts把域名指定到某IP下。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Thu, 28 Jan 2010 07:38:03 +0000</pubDate> 
<guid>http://jackxiang.com/post/2656/</guid> 
<description>
<![CDATA[ 
	curl之CURLOPT_HTTPHEADER<br/><br/>单个<br/><br/><div class="code">&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php<br/>&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_HTTPHEADER, array(&quot;Range: Bytes=0-50&#92;n&quot;));<br/>&nbsp;&nbsp;&nbsp;&nbsp;?&gt;</div>多个<br/><br/><div class="code">&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php<br/>&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_HTTPHEADER, array(&quot;Range: Bytes=0-50&#92;nOtherheader: stuff&#92;n&quot;));<br/>&nbsp;&nbsp;&nbsp;&nbsp;?&gt;</div><br/><br/>我们在不设置host的时候提交到虚拟主机后，会出现：<br/><br/><div class="code"><br/>Tencent:/usr/local/tads/htdocs/mhxy2010hn.act/crontab # curl &quot;http://172.23.129.11*/user_v3/freere*g.php?act_id=109353&quot;<br/>&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 2.0//EN&quot;&gt;<br/>&lt;html&gt;&lt;head&gt;<br/>&lt;title&gt;404 Not Found&lt;/title&gt;<br/>&lt;/head&gt;&lt;body&gt;<br/>&lt;h1&gt;Not Found&lt;/h1&gt;<br/>&lt;p&gt;The requested URL /user_v3/freereg.php was not found on this server.&lt;/p&gt;<br/>&lt;/body&gt;&lt;/html&gt;</div><br/><br/>设置host后就能找到了。<br/><br/>curl为我们用了CURLOPT_HTTPHEADER来做host的工作：<br/><br/><br/><br/><div class="code">function curl_post($host, $data)<br/>&#123;<br/><br/>&nbsp;&nbsp;$ch = curl_init();<br/>&nbsp;&nbsp;$res= curl_setopt ($ch, CURLOPT_URL,$host);<br/>&nbsp;&nbsp;curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);<br/>&nbsp;&nbsp;curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);<br/>&nbsp;&nbsp;curl_setopt ($ch, CURLOPT_HEADER, 0);<br/>&nbsp;&nbsp;curl_setopt($ch, CURLOPT_POST, 1);<br/>&nbsp;&nbsp;curl_setopt($ch, CURLOPT_POSTFIELDS, $data);<br/>&nbsp;&nbsp;curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);<br/>&nbsp;&nbsp;curl_setopt($ch,CURLOPT_HTTPHEADER,array(&quot;Host: act.*.qq.com&quot;));<br/><br/>&nbsp;&nbsp;$xyz = curl_exec ($ch);<br/><br/>&nbsp;&nbsp;//echo $xyz;<br/><br/>&nbsp;&nbsp;if ($xyz == NULL) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br/>&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;return $xyz;<br/><br/>&#125;</div><br/><br/><br/>相当于：<br/><br/><div class="code">172.23.129.*&nbsp;&nbsp;act.*.qq.com</div><br/><br/>这样一折腾，就ok了，呵呵！<br/>其实这个主要是解决，在线上有host指向了，但是其他的需哟又需要这个host的域名，而ip不同的情况。<br/><br/>—————————————————————————————————————————————————<br/>用Curl直接模拟Host如下：<br/><textarea name="code" class="php" rows="15" cols="100">
&nbsp;&nbsp;&nbsp;&nbsp;curl -l -H &quot;Host:test3.qq.com&quot;&nbsp;&nbsp;http://17.2*.*.70/index.php&nbsp;&nbsp;&nbsp;&nbsp; 
</textarea><br/>以上摘录自：http://jackxiang.com/post/4022/
]]>
</description>
</item><item>
<link>http://jackxiang.com/post/2656/#blogcomment51589</link>
<title><![CDATA[[评论] curl之CURLOPT_HTTPHEADER设置header头，还能实现不用设置Hosts把域名指定到某IP下。]]></title> 
<author>fc_lamp &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 02 Jul 2010 08:46:02 +0000</pubDate> 
<guid>http://jackxiang.com/post/2656/#blogcomment51589</guid> 
<description>
<![CDATA[ 
	good
]]>
</description>
</item>
</channel>
</rss>