equal
deleted
inserted
replaced
53 _UNTRUSTED_REQUEST_HEADERS = frozenset([ |
53 _UNTRUSTED_REQUEST_HEADERS = frozenset([ |
54 'accept-encoding', |
54 'accept-encoding', |
55 'content-length', |
55 'content-length', |
56 'host', |
56 'host', |
57 'referer', |
57 'referer', |
58 'user-agent', |
|
59 'vary', |
58 'vary', |
60 'via', |
59 'via', |
61 'x-forwarded-for', |
60 'x-forwarded-for', |
62 ]) |
61 ]) |
63 |
62 |
102 if not (protocol == 'http' or protocol == 'https'): |
101 if not (protocol == 'http' or protocol == 'https'): |
103 logging.error('Invalid protocol: %s', protocol) |
102 logging.error('Invalid protocol: %s', protocol) |
104 raise apiproxy_errors.ApplicationError( |
103 raise apiproxy_errors.ApplicationError( |
105 urlfetch_service_pb.URLFetchServiceError.INVALID_URL) |
104 urlfetch_service_pb.URLFetchServiceError.INVALID_URL) |
106 |
105 |
|
106 if not host: |
|
107 logging.error('Missing host.') |
|
108 raise apiproxy_errors.ApplicationError( |
|
109 urlfetch_service_pb.URLFetchServiceError.FETCH_ERROR) |
|
110 |
107 sanitized_headers = self._SanitizeHttpHeaders(_UNTRUSTED_REQUEST_HEADERS, |
111 sanitized_headers = self._SanitizeHttpHeaders(_UNTRUSTED_REQUEST_HEADERS, |
108 request.header_list()) |
112 request.header_list()) |
109 request.clear_header() |
113 request.clear_header() |
110 request.header_list().extend(sanitized_headers) |
114 request.header_list().extend(sanitized_headers) |
111 |
115 |
144 if port not in PORTS_ALLOWED_IN_PRODUCTION: |
148 if port not in PORTS_ALLOWED_IN_PRODUCTION: |
145 logging.warning( |
149 logging.warning( |
146 'urlfetch received %s ; port %s is not allowed in production!' % |
150 'urlfetch received %s ; port %s is not allowed in production!' % |
147 (url, port)) |
151 (url, port)) |
148 |
152 |
149 if host == '' and protocol == '': |
153 if protocol and not host: |
|
154 logging.error('Missing host on redirect; target url is %s' % url) |
|
155 raise apiproxy_errors.ApplicationError( |
|
156 urlfetch_service_pb.URLFetchServiceError.FETCH_ERROR) |
|
157 |
|
158 if not host and not protocol: |
150 host = last_host |
159 host = last_host |
151 protocol = last_protocol |
160 protocol = last_protocol |
152 |
161 |
153 adjusted_headers = { |
162 adjusted_headers = { |
154 'Host': host, |
163 'Host': host, |