| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import re | 6 import re |
| 7 import urlparse | 7 import urlparse |
| 8 | 8 |
| 9 from common.codereview import CodeReview | 9 from common.codereview import CodeReview |
| 10 from common.http_client_appengine import HttpClientAppengine | 10 from common.http_client_appengine import HttpClientAppengine |
| 11 | 11 |
| 12 | 12 |
| 13 _RIETVELD_ISSUE_NUMBER_RE = re.compile('^/(\d+)/?.*') | 13 _RIETVELD_ISSUE_NUMBER_RE = re.compile('^/(\d+)/?.*') |
| 14 | 14 |
| 15 | 15 |
| 16 class Rietveld(CodeReview): | 16 class Rietveld(CodeReview): |
| 17 """The implementation of CodeReview interface for Rietveld.""" | 17 """The implementation of CodeReview interface for Rietveld.""" |
| 18 HTTP_CLIENT = HttpClientAppengine() | 18 HTTP_CLIENT = HttpClientAppengine(follow_redirects=False) |
| 19 | 19 |
| 20 def _GetXsrfToken(self, rietveld_url): | 20 def _GetXsrfToken(self, rietveld_url): |
| 21 """Returns the xsrf token for follow-up requests.""" | 21 """Returns the xsrf token for follow-up requests.""" |
| 22 headers = { | 22 headers = { |
| 23 'X-Requesting-XSRF-Token': '1', | 23 'X-Requesting-XSRF-Token': '1', |
| 24 'Accept': 'text/plain', | 24 'Accept': 'text/plain', |
| 25 } | 25 } |
| 26 url = '%s/xsrf_token' % rietveld_url | 26 url = '%s/xsrf_token' % rietveld_url |
| 27 status_code, xsrf_token = self.HTTP_CLIENT.Post( | 27 status_code, xsrf_token = self.HTTP_CLIENT.Post( |
| 28 url, data=None, headers=headers) | 28 url, data=None, headers=headers) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 'no_redirect': 'True', | 77 'no_redirect': 'True', |
| 78 } | 78 } |
| 79 content_type, body = self._EncodeMultipartFormData(form_fields) | 79 content_type, body = self._EncodeMultipartFormData(form_fields) |
| 80 headers = { | 80 headers = { |
| 81 'Content-Type': content_type, | 81 'Content-Type': content_type, |
| 82 'Accept': 'text/plain', | 82 'Accept': 'text/plain', |
| 83 } | 83 } |
| 84 status_code, content = self.HTTP_CLIENT.Post( | 84 status_code, content = self.HTTP_CLIENT.Post( |
| 85 url, data=body, headers=headers) | 85 url, data=body, headers=headers) |
| 86 return status_code == 200 and content == 'OK' | 86 return status_code == 200 and content == 'OK' |
| OLD | NEW |