[Twisted-Python] Can browse, but getPage() fails on localhost address
I can browse to either URL in any browser, getPage() works fine on the external address, 404's on the localhost address. Any insight greatly appreciated; this is about as simple a test case as there can be and I'm mystified as to why it's not working. Of course, that probably means I'll feel like a complete moron when someone clops me on the head with the answer, but I can deal with that... Thanks, S Just in case it gets mutilated by mail: http://pastebin.com/d2f80ce0a from twisted.web import client def showPage(pageData): print pageData reactor.stop() def handleError(failure): print "Error:", failure.getErrorMessage() failure.printDetailedTraceback() reactor.stop() if __name__ == "__main__": from twisted.internet import reactor # postRequest = client.getPage("http://localhost/w3c-validator/check ") postRequest = client.getPage("http://validator.w3.org/check") postRequest.addCallback(showPage).addErrback(handleError) reactor.run()
On Thursday 29 October 2009, Steve Steiner (listsin) wrote:
I can browse to either URL in any browser, getPage() works fine on the external address, 404's on the localhost address.
Does the same thing happen with "127.0.0.1" instead of "localhost" in the URL? I once encountered a nasty setup where a machine itself did not have "localhost" in /etc/hosts and the DNS server returned the IP address of another machine on the network... Bye, Maarten
On Oct 29, 2009, at 1:10 PM, Maarten ter Huurne wrote:
On Thursday 29 October 2009, Steve Steiner (listsin) wrote:
I can browse to either URL in any browser, getPage() works fine on the external address, 404's on the localhost address.
Does the same thing happen with "127.0.0.1" instead of "localhost" in the URL? I once encountered a nasty setup where a machine itself did not have "localhost" in /etc/hosts and the DNS server returned the IP address of another machine on the network...
Yes, unfortunately, same thing and the hosts file is also correct. This is in OS X, and the valida†or URL I'm calling is being served by Apache 2.2, and is a ScriptAlias like so (in an includ of httpd.conf): ScriptAlias /w3c-validator/check '/Applications/Validator- SAC.app/Contents/Resources/validator/httpd/cgi-bin/check_wrapper.sh' Thing that's got me baffled is that I can go to it just fine in a browser, I can `curl` it, but, now, after a little more digging, wget can't get it either! So: curl http://localhost/w3c-validator/check <-- returns HTML code any browser to http://localhost/w3c-validator/check <-- returns HTML code t.w.c.getPage("http://localhost/w3c-validator/check") <-- 404 wget http://localhost/w3c-validator/check <-- 404 So what the heck is the difference in how these things resolve that address!? Thanks, S
On Thu, Oct 29, 2009 at 12:36 PM, Steve Steiner (listsin) < listsin@integrateddevcorp.com> wrote:
On Oct 29, 2009, at 1:10 PM, Maarten ter Huurne wrote:
On Thursday 29 October 2009, Steve Steiner (listsin) wrote:
I can browse to either URL in any browser, getPage() works fine on the external address, 404's on the localhost address.
Does the same thing happen with "127.0.0.1" instead of "localhost" in the URL? I once encountered a nasty setup where a machine itself did not have "localhost" in /etc/hosts and the DNS server returned the IP address of another machine on the network...
Yes, unfortunately, same thing and the hosts file is also correct.
This is in OS X, and the valida†or URL I'm calling is being served by Apache 2.2, and is a ScriptAlias like so (in an includ of httpd.conf):
ScriptAlias /w3c-validator/check '/Applications/Validator- SAC.app/Contents/Resources/validator/httpd/cgi-bin/check_wrapper.sh'
Thing that's got me baffled is that I can go to it just fine in a browser, I can `curl` it, but, now, after a little more digging, wget can't get it either!
So: curl http://localhost/w3c-validator/check <-- returns HTML code any browser to http://localhost/w3c-validator/check <-- returns HTML code t.w.c.getPage("http://localhost/w3c-validator/check") <-- 404 wget http://localhost/w3c-validator/check <-- 404
So what the heck is the difference in how these things resolve that address!?
Thanks,
S
When you say "resolve that address" do you mean the IP Address or the URL? If the requests are in fact going to the same address (IP), I would take a look at the HTTP headers for each method and compare them. Wget failing in a similar fashion to getPage() may actually help you diagnose this. Kevin Horn
participants (3)
-
Kevin Horn
-
Maarten ter Huurne
-
Steve Steiner (listsin)