thirdparty/google_appengine/google/appengine/api/urlfetch_stub.py
changeset 2273 e4cb9c53db3e
parent 828 f5fd65cc3bf3
child 2309 be1b94099f2d
--- a/thirdparty/google_appengine/google/appengine/api/urlfetch_stub.py	Tue Apr 21 16:28:13 2009 +0000
+++ b/thirdparty/google_appengine/google/appengine/api/urlfetch_stub.py	Fri Apr 24 14:16:00 2009 +0000
@@ -55,7 +55,6 @@
   'content-length',
   'host',
   'referer',
-  'user-agent',
   'vary',
   'via',
   'x-forwarded-for',
@@ -104,6 +103,11 @@
       raise apiproxy_errors.ApplicationError(
         urlfetch_service_pb.URLFetchServiceError.INVALID_URL)
 
+    if not host:
+      logging.error('Missing host.')
+      raise apiproxy_errors.ApplicationError(
+          urlfetch_service_pb.URLFetchServiceError.FETCH_ERROR)
+
     sanitized_headers = self._SanitizeHttpHeaders(_UNTRUSTED_REQUEST_HEADERS,
                                                   request.header_list())
     request.clear_header()
@@ -146,7 +150,12 @@
           'urlfetch received %s ; port %s is not allowed in production!' %
           (url, port))
 
-      if host == '' and protocol == '':
+      if protocol and not host:
+        logging.error('Missing host on redirect; target url is %s' % url)
+        raise apiproxy_errors.ApplicationError(
+          urlfetch_service_pb.URLFetchServiceError.FETCH_ERROR)
+
+      if not host and not protocol:
         host = last_host
         protocol = last_protocol