thirdparty/google_appengine/google/appengine/api/urlfetch.py
changeset 297 35211afcd563
parent 149 f2e327a7c5de
child 686 df109be0567c
equal deleted inserted replaced
296:b02dd2a5f329 297:35211afcd563
   173       "PATH_INFO" not in os.environ):
   173       "PATH_INFO" not in os.environ):
   174     return False
   174     return False
   175 
   175 
   176   scheme, host_port, path, query, fragment = urlparse.urlsplit(url)
   176   scheme, host_port, path, query, fragment = urlparse.urlsplit(url)
   177 
   177 
   178   if (host_port == os.environ['HTTP_HOST'] and
   178   if host_port == os.environ['HTTP_HOST']:
   179       urllib2.unquote(path) == urllib2.unquote(os.environ['PATH_INFO'])):
   179     current_path = urllib2.unquote(os.environ['PATH_INFO'])
   180     return True
   180     desired_path = urllib2.unquote(path)
       
   181 
       
   182     if (current_path == desired_path or
       
   183         (current_path in ('', '/') and desired_path in ('', '/'))):
       
   184       return True
   181 
   185 
   182   return False
   186   return False
   183 
   187 
   184 
   188 
   185 def fetch(url, payload=None, method=GET, headers={}, allow_truncated=False,
   189 def fetch(url, payload=None, method=GET, headers={}, allow_truncated=False,
   262         urlfetch_service_pb.URLFetchServiceError.FETCH_ERROR):
   266         urlfetch_service_pb.URLFetchServiceError.FETCH_ERROR):
   263       raise DownloadError(str(e))
   267       raise DownloadError(str(e))
   264     if (e.application_error ==
   268     if (e.application_error ==
   265         urlfetch_service_pb.URLFetchServiceError.RESPONSE_TOO_LARGE):
   269         urlfetch_service_pb.URLFetchServiceError.RESPONSE_TOO_LARGE):
   266       raise ResponseTooLargeError(None)
   270       raise ResponseTooLargeError(None)
       
   271     if (e.application_error ==
       
   272         urlfetch_service_pb.URLFetchServiceError.DEADLINE_EXCEEDED):
       
   273       raise DownloadError(str(e))
   267     raise e
   274     raise e
   268   result = _URLFetchResult(response)
   275   result = _URLFetchResult(response)
   269 
   276 
   270   if not allow_truncated and response.contentwastruncated():
   277   if not allow_truncated and response.contentwastruncated():
   271     raise ResponseTooLargeError(result)
   278     raise ResponseTooLargeError(result)