[Twisted-Python] Can browse, but getPage() fails on localhost address
Steve Steiner (listsin)
listsin at integrateddevcorp.com
Thu Oct 29 18:47:09 EDT 2009
On Oct 29, 2009, at 3:29 PM, Steve Steiner (listsin) wrote:
> On Oct 29, 2009, at 2:01 PM, Terry Jones wrote:
>
>>>>>>> "Steve" == Steve Steiner (listsin)
>>>>>>> <listsin at integrateddevcorp.com> writes:
>> Steve> curl http://localhost/w3c-validator/check <-- returns
>> HTML code
>> Steve> any browser to http://localhost/w3c-validator/check <--
>> returns HTML code
>>
>> Steve> t.w.c.getPage("http://localhost/w3c-validator/check") <-- 404
>> Steve> wget http://localhost/w3c-validator/check <-- 404
>>
>> Steve> So what the heck is the difference in how these things
>> resolve that
>> Steve> address!?
>>
>> When you say 404, do you really mean that you get a 404? Or are you
>> just
>> saying that to informally tell us that it doesn't work?
>
> No, I mean this, exactly:
>
> # wget http://localhost/w3c-validator/check
> --2009-10-29 13:31:40-- http://localhost/w3c-validator/check
> Resolving localhost... 127.0.0.1, ::1, fe80::1
> Connecting to localhost|127.0.0.1|:80... connected.
> HTTP request sent, awaiting response... 404 Not Found
> 2009-10-29 13:31:40 ERROR 404: Not Found.
>
> # python foo.py
> Error: 404 Not Found
> *--- Failure #6 ---
> Failure: twisted.web.error.Error: 404 Not Found
> *--- End of Failure #6 ---
>
> That last is from failure.printDetailedTraceback().
The only difference between the requests, as far as I can see (via
tcpdump et al.), is that both `curl` and my browsers send HTTP/1.1
requests and both `wget` and t.w.c.getPage() send HTTP/1.0.
This code also works:
import httplib
headers = { "Accept":"*/*"}
h1 = httplib.HTTPConnection("localhost")
h1.connect()
h1.request("GET", url="/w3c-validator/check", headers=headers)
rsp = h1.getresponse()
print rsp.read()
Does this make any sense, that an HTTP/1.1 request would succeed where
a simple HTTP/1.0 request returns a 404?
Maybe it's time to whip out that /twisted-branch-high-level-web-
client-3987 I checked out a while ago...
S
More information about the Twisted-Python
mailing list