Skip to content

修复响应头notice#1

Merged
Yurunsoft merged 4 commits intoYurunsoft:masterfrom
jtunggit:master
Jun 13, 2017
Merged

修复响应头notice#1
Yurunsoft merged 4 commits intoYurunsoft:masterfrom
jtunggit:master

Conversation

@jtunggit
Copy link
Copy Markdown
Contributor

修复响应头 当行没有 : 时错出 bug,如:HTTP/1.1 200 OK 会抛 notice 错误

jtunggit added 3 commits June 10, 2017 12:45
修复响应头 当行没有 : 时错出 bug,如:HTTP/1.1 200 OK 会抛 notice 错误
修改说明
修改
@Yurunsoft
Copy link
Copy Markdown
Owner

我这边不会出现notice,能否提供一下会出现notice的调试代码?

fix 错误写法.
@Yurunsoft
Copy link
Copy Markdown
Owner

试了一下,也没有出notice
image
image

@jtunggit
Copy link
Copy Markdown
Contributor Author

你的 error_reportting 忽略了?

@Yurunsoft
Copy link
Copy Markdown
Owner

没有忽略,其它notice能显示的。。你是什么版本?

@jtunggit
Copy link
Copy Markdown
Contributor Author

php -version
PHP 7.1.5-1+deb.sury.org~xenial+1 (cli) (built: May 11 2017 14:07:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

@Yurunsoft
Copy link
Copy Markdown
Owner

PHP 7.0.1 (cli) (built: Dec 16 2015 13:36:28) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

PHP5.3和5.5也都试过了,没有出现notice

@Yurunsoft
Copy link
Copy Markdown
Owner

image
下了个7.1试了下,也没有notice

@jtunggit
Copy link
Copy Markdown
Contributor Author

$http->retry(3)
->ua('Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1')
->referer('https://m.baidu.com/')
->accept('text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8')
->acceptLanguage('zh-CN,zh;q=0.8');
我的代码如上,百度的头里面会返回最后一行是 HTTP 1.0 OK,没有 : 分隔,所以就会notice

@jtunggit
Copy link
Copy Markdown
Contributor Author

array(26) {
[0]=>
string(30) "HTTP/1.1 301 Moved Permanently"
[1]=>
string(35) "Date: Sun, 11 Jun 2017 12:18:29 GMT"
[2]=>
string(23) "Content-Type: text/html"
[3]=>
string(19) "Content-Length: 178"
[4]=>
string(22) "Connection: keep-alive"
[5]=>
string(74) "Set-Cookie: aliyungf_tc=AQAAAKM4xUYKGAoAqRn5OjEUMpg8l6TB; Path=/; HttpOnly"
[6]=>
string(49) "Location: https://www.zhihu.com/question/28596521"
[7]=>
string(24) "X-Req-ID: 28DEA9593D3515"
[8]=>
string(11) "Server: ZWS"
[9]=>
string(21) "Vary: Accept-Encoding"
[10]=>
string(0) ""
[11]=>
string(15) "HTTP/1.1 200 OK"
[12]=>
string(35) "Date: Sun, 11 Jun 2017 12:18:36 GMT"
[13]=>
string(38) "Content-Type: text/html; charset=utf-8"
[14]=>
string(21) "Content-Length: 38284"
[15]=>
string(22) "Connection: keep-alive"
[16]=>
string(74) "Set-Cookie: aliyungf_tc=AQAAAMcYP2natQUAqRn5OlAuy4YtXcGd; Path=/; HttpOnly"
[17]=>
string(16) "Pragma: no-cache"
[18]=>
string(38) "Expires: Fri, 02 Jan 2000 00:00:00 GMT"
[19]=>
string(21) "X-Frame-Options: DENY"
[20]=>
string(91) "Cache-Control: private,no-store,max-age=0,no-cache,must-revalidate,post-check=0,pre-check=0"
[21]=>
string(420) "Content-Security-Policy: default-src * blob:;img-src * data: blob:;frame-src 'self' *.zhihu.com getpocket.com note.youdao.com safari-extension://com.evernote.safari.clipper-Q79WDW8YH9 weixin: static.hdslb.com player.youku.com v.qq.com;script-src 'self' *.zhihu.com *.google-analytics.com zhstatic.zhihu.com res.wx.qq.com 'unsafe-eval' unpkg.zhimg.com blob:;style-src 'self' *.zhihu.com 'unsafe-inline';connect-src * wss:"
[22]=>
string(25) "X-Req-ID: 200FC73593D351C"
[23]=>
string(64) "X-Req-SSL: proto=TLSv1.2,sni=,cipher=ECDHE-RSA-AES256-GCM-SHA384"
[24]=>
string(11) "Server: ZWS"
[25]=>
string(21) "Vary: Accept-Encoding"
}
PHP Notice 'yii\base\ErrorException' with message 'Undefined offset: 1'

yurun-http/HttpResponse.php:110

@Yurunsoft
Copy link
Copy Markdown
Owner

用上面的代码确实有问题,下次更新合并过来

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants