does not handle HTTP 301 "errors", should follow them

Bug #523045 reported by Michael Rooney on 2010-02-17
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lazr.restfulclient
Low
Unassigned

Bug Description

Hello! I'm using the Launchpad API and finding that I get the following:

Traceback (most recent call last):
  File "./release.py", line 117, in <module>
    main(server, config.LP_USER, projectName, version)
  File "./release.py", line 110, in main
    releaser = Releaser(lp, projectName, version)
  File "./release.py", line 17, in __init__
    self._Initialize()
  File "./release.py", line 23, in _Initialize
    self.Milestone = self.Project.getMilestone(name=version)
  File "/usr/lib/python2.6/dist-packages/lazr/restfulclient/resource.py", line 460, in __call__
    url, in_representation, http_method, extra_headers=extra_headers)
  File "/usr/lib/python2.6/dist-packages/lazr/restfulclient/_browser.py", line 204, in _request
    raise HTTPError(response, content)
lazr.restfulclient.errors.HTTPError: HTTP Error 301: Moved Permanently

This happens if I supply a project name of "Foo" when the project name in Launchpad is "foo". Because LP is case-insensitive, it redirects to the proper project, and it would be most convenient if lazr followed this, instead of treating a 301 as an error.

Thanks! Let me know if I can provide more information or if this belongs in another project.

Changed in lazr.restfulclient:
status: New → Triaged
importance: Undecided → Medium
Changed in lazr.restfulclient:
status: Triaged → Fix Released
status: Fix Released → Confirmed
Leonard Richardson (leonardr) wrote :

The error only occurs when invoking a named operation that results in a redirect. The underlying problem is that the HTTP method comes out of the WADL file in lowercase, and there's code in httplib2 that checks the HTTP method against a list of uppercase method names. "get" doesn't match "GET", so httplib2 thinks we're not doing a safe HTTP request and refuses to automatically follow the redirect.

I have a fix in lazr.restfulclient, but I'll need to add some code to lazr.restful to write a test for it. I should also file or find an httplib2 bug.

Changed in lazr.restfulclient:
status: Confirmed → Triaged
Changed in lazr.restfulclient:
importance: Medium → Low
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers