PHP Class Cml\Vendor\Http

Show file Open project: linhecheng/cmlphp

Public Methods

Method Description
curlDownload ( string $remote, string $local ) : mixed 采集远程文件
download ( string $filename, string $showname = '', string $content = '', integer $expire = 180 ) : void 下载文件 可以指定下载显示的文件名,并自动发送相应的Header信息 如果指定了content参数,则下载该参数的内容
fsockopenDownload ( string $url, array $conf = [] ) : mixed 使用 fsockopen 通过 HTTP 协议直接访问(采集)远程文件 如果主机或服务器没有开启 CURL 扩展可考虑使用 fsockopen 比 CURL 稍慢,但性能稳定
getHeaderInfo ( string $header = '', boolean $echo = true ) : string 显示HTTP Header 信息
mimeContentType ( string $filename ) : string 获取文件的mime_content类型
sendHttpStatus ( integer $code ) HTTP Protocol defined status codes

Method Details

curlDownload() public static method

采集远程文件
public static curlDownload ( string $remote, string $local ) : mixed
$remote string 远程文件名
$local string 本地保存文件名
return mixed

download() public static method

下载文件 可以指定下载显示的文件名,并自动发送相应的Header信息 如果指定了content参数,则下载该参数的内容
public static download ( string $filename, string $showname = '', string $content = '', integer $expire = 180 ) : void
$filename string 下载文件名
$showname string 下载显示的文件名
$content string 下载的内容
$expire integer 下载内容浏览器缓存时间
return void

fsockopenDownload() public static method

使用 fsockopen 通过 HTTP 协议直接访问(采集)远程文件 如果主机或服务器没有开启 CURL 扩展可考虑使用 fsockopen 比 CURL 稍慢,但性能稳定
public static fsockopenDownload ( string $url, array $conf = [] ) : mixed
$url string 远程URL
$conf array 其他配置信息 int limit 分段读取字符个数 string post post的内容,字符串或数组,key=value&形式 string cookie 携带cookie访问,该参数是cookie内容 string ip 如果该参数传入,$url将不被使用,ip访问优先 int timeout 采集超时时间 bool block 是否阻塞访问,默认为true
return mixed

getHeaderInfo() public static method

显示HTTP Header 信息
public static getHeaderInfo ( string $header = '', boolean $echo = true ) : string
$header string
$echo boolean
return string

mimeContentType() public static method

获取文件的mime_content类型
public static mimeContentType ( string $filename ) : string
$filename string
return string

sendHttpStatus() public static method

HTTP Protocol defined status codes
public static sendHttpStatus ( integer $code )
$code integer