Weird error with urlfetch and localhost

I'm getting a weird Invalid Argument error while trying to hit localhost with urlfetch in the latest Google App Engine SDK.

I traced the issue to the _RetrieveURL method in /usr/local/google_appengine/google/appengine/api/urlfetch_stub.py and implemented a quick hack, adding the following at line 152:

# Aral - hack: for some reason urlfetch doesn't like localhost
# so we translate it to 127.0.0.1. This is for local testing only.
if host == 'localhost:8080':
  host = '127.0.0.1:8080'

This basically allows me to hit one instance of the local dev server from another for testing some functionality I need for the Google App Engine backup/restore solution I'm working on. Without this hack, I can't hit localhost with urlfetch at all.

I'm still not sure why this is happening. (Could appenginepatch be messing things up — it was working under AppEngineHelper... hmm?)

Comments