不支持HTTP / 1.1 505 HTTP版本 [英] HTTP/1.1 505 HTTP Version Not Supported

查看:228
本文介绍了不支持HTTP / 1.1 505 HTTP版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行PHP脚本来抓取网页。它适用于许多网站,但有一个网站失败,返回错误HTTP / 1.1 505 HTTP版本不支持。



这是(部分)我的脚本:

  for($ i = 0; $ i< 1; $ i ++){
$ page = file_get_contents(http://www.lovelybooks.de/stoebern/empfehlung/romantic fantasy /?seite = $ i);
//用$ page做一些事情
}

许多答案建议设置HTTP版本明确。我尝试过设置0.9,1.0和1.1,但它没有改变任何东西。实际上,标题似乎表明我的浏览器请求的HTTP版本和服务器期望的HTTP版本匹配:



回复标题:

  HTTP / 1.1 200 OK 
日期:星期一,2014年12月15日09:01:15 GMT
服务器:Apache
X-技术支持:PHP / 5.4.35
Keep-Alive:timeout = 2,max = 200
连接:Keep-Alive
Transfer-Encoding:chunked
Content-Type: text / html

请求标题:

  GET /path/script.php HTTP / 1.1 
主持人:www.mydoman.de
用户代理:Mozilla / 5.0(Macintosh; Intel Mac OS X 10.9; rv:34.0)Gecko / 20100101 Firefox / 34.0
接受:text / html,application / xhtml + xml,application / xml; q = 0.9,* / *; q = 0.8
Accept-Language:de ,en-US; q = 0.7,en; q = 0.3
Accept-Encoding:gzip,deflate
DNT:1
授权:基本MjQwMjE5Njc6MDcwNjIwMDc =
连接:keep-alive
缓存控制:max-age = 0

还有什么可能是错误的?

  $ page = file_get_contents(http://www.lovelybooks.de/stoebern/empfehlung/romantic%20fantasy/?seite=$i); 


I'm running a PHP script to grab a web page. It worked fine with many sites, but with one site it fails, returning an error saying "HTTP/1.1 505 HTTP Version Not Supported".

This is (part of) my script:

for($i = 0; $i < 1; $i++) {
    $page = file_get_contents("http://www.lovelybooks.de/stoebern/empfehlung/romantic fantasy/?seite=$i");
    // do something with $page
}

Many answers recommend setting the HTTP version explicity. I have tried setting 0.9, 1.0 and 1.1, but it did not change anything. And actually the headers seems to show that the HTTP version requested by my browser and that expected by the server match:

Reply headers:

HTTP/1.1 200 OK
Date: Mon, 15 Dec 2014 09:01:15 GMT
Server: Apache
X-Powered-By: PHP/5.4.35
Keep-Alive: timeout=2, max=200
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

Request headers:

GET /path/script.php HTTP/1.1
Host: www.mydoman.de
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:34.0) Gecko/20100101 Firefox/34.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Authorization: Basic MjQwMjE5Njc6MDcwNjIwMDc=
Connection: keep-alive
Cache-Control: max-age=0

What else can be wrong?

解决方案

Replace the space in the URL with its percent-encoding:

    $page = file_get_contents("http://www.lovelybooks.de/stoebern/empfehlung/romantic%20fantasy/?seite=$i");

这篇关于不支持HTTP / 1.1 505 HTTP版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆