3841: rbtools.api.request hardcodes http return codes

yaneu******@gmai***** (Google Code) (Is this you? Claim this profile.)
ahache
Version

0.7.2

Note: this is based purely on code inspection. These numbers should be derived from the httplib module, not hardcoded in the code.

196 class ReviewBoardHTTPErrorProcessor(HTTPErrorProcessor):
197     """Processes HTTP error codes.
198 
199     Python 2.6 gets HTTP error code processing right, but 2.4 and 2.5 only
200     accepts HTTP 200 and 206 as success codes. This handler ensures that
201     anything in the 200 range, as well as 304, is a success.
202     """
203     def http_response(self, request, response):
204         if not (200 <= response.code < 300 or response.code == 304):
205             response = self.parent.error('http', request, response,
206                                          response.code, response.msg,
207                                          response.info())
208 
209         return response
#1 yaneu******@gmai***** (Google Code) (Is this you? Claim this profile.)
Here's another hardcoded instance..

277         except HTTPError as e:
278             if e.code == 401:
chipx86
#2 chipx86
HTTP status codes aren't changing any time soon. I'm not sure this is worth changing. Particularly since those working on HTTP code should absolutely be familiar with the various status codes, and seeing those codes here means not having to look up a constant in some documentation.
#3 yaneu******@gmai***** (Google Code) (Is this you? Claim this profile.)
They shouldn't change anytime soon, but it makes reading the code to determine where and what's going on a bit easier.
david
#4 david
  • +Component-RBTools
    +EasyFix
#6 ahache
I'll pick this up as an easy-fix bug.
#7 ahache
Review Request #7625 created for this issue.
david
#8 david
  • -reviewboard
    +rbtools
#9 ahache
  • +ahache
brennie
#10 brennie

This was fixed in in commit 72ccc5d.

  • -New
    +Fixed