Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: gcl.py

Issue 5015005: Fix XSRF token in gcl so we don't need to hack rietveld anymore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcl.py
diff --git a/gcl.py b/gcl.py
index b3374d9d642d8c0a4490e65b85669491e3862c97..c0d6685e4ba7edd1f0cb6a71de29755d9c43b3fb 100755
--- a/gcl.py
+++ b/gcl.py
@@ -343,15 +343,26 @@ class ChangeInfo(object):
def CloseIssue(self):
"""Closes the Rietveld issue for this changelist."""
- data = [("description", self.description),]
+ # Newer versions of Rietveld require us to pass an XSRF token to POST, so
+ # we fetch it from the server.
+ xsrf_token = self.SendToRietveld(
+ '/xsrf_token',
+ extra_headers={'X-Requesting-XSRF-Token': '1'})
+
+ # You cannot close an issue with a GET.
+ # We pass an empty string for the data so it is a POST rather than a GET.
+ data = [("description", self.description),
+ ("xsrf_token", xsrf_token)]
ctype, body = upload.EncodeMultipartFormData(data, [])
- self.SendToRietveld('/%d/close' % self.issue, body, ctype)
+ self.SendToRietveld('/%d/close' % self.issue, payload=body,
+ content_type=ctype)
def UpdateRietveldDescription(self):
"""Sets the description for an issue on Rietveld."""
data = [("description", self.description),]
ctype, body = upload.EncodeMultipartFormData(data, [])
- self.SendToRietveld('/%d/description' % self.issue, body, ctype)
+ self.SendToRietveld('/%d/description' % self.issue, payload=body,
+ content_type=ctype)
def GetIssueDescription(self):
"""Returns the issue description from Rietveld."""
@@ -364,8 +375,7 @@ class ChangeInfo(object):
self.SendToRietveld('/lint/issue%s_%s' % (self.issue, self.patchset),
timeout=1)
- def SendToRietveld(self, request_path, payload=None,
- content_type="application/octet-stream", timeout=None):
+ def SendToRietveld(self, request_path, timeout=None, **kwargs):
"""Send a POST/GET to Rietveld. Returns the response body."""
if not self.rietveld:
ErrorExit(CODEREVIEW_SETTINGS_FILE_NOT_FOUND)
@@ -379,7 +389,7 @@ class ChangeInfo(object):
GetUserCredentials,
save_cookies=True)
try:
- return rpc_server.Send(request_path, payload, content_type, timeout)
+ return rpc_server.Send(request_path, timeout=timeout, **kwargs)
except urllib2.URLError:
if timeout is None:
ErrorExit('Error accessing url %s' % request_path)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698