当先锋百科网

首页 1 2 3 4 5 6 7
<?php
/**
 * 封装基于curl的HTTP类库
 *
 * @file    class_httplib.php
 * @author	[email protected]
 * @date    2013-8-1
 */
class httplib{
	private $response;
	private $response_header;
	private $response_data;
	private $response_info;
	private $response_httpcode;
	private $timeout = 30;
	private $cookie = '';
	private $useragent = 'PHP-HttpLib-v1.0';
	private $request_header = array();
	private $starttime;
	private $request_proxy = array();
	private $request_method;
	public function __construct(){
		$this->starttime = self::_microtime();
		//能有效提高POST大于1M数据时的请求速度
		$this->set_header('Expect');
	}
	/**
	 * 设置cookie(可选)
	 * @param <array|string> $cookie
	 */
	public function set_cookie($cookie = ''){
		if (is_array($cookie)){
			$cookies = array();
			foreach ($cookie as $k => $v){
				$cookies[] = $k.'='.$v;
			}
			$this->cookie .= implode('; ',