Public bug reported:
This is a general problem, but I'll mention the parts where it's causing
me pain. I wrote a launchpadlib class that can act as a trusted client,
the equivalent of the user's web browser. Because it's not a web browser
and no one's looking at the HTML, I need to set the status codes
properly to convey different error conditions. Here's the code I have:
1. A GET request that asks for a media type of application/json.
1A. If the response status is 200 and the Location header contains the string
"+login", the response status should actually be 401.
1B. Otherwise, if the media type is not application/json, I assume there has
been a server-side error and I change the status code to 500.
2. A POST request to authorize an OAuth request token.
2A. If the response entity-body contains the string "Unauthenticated user
POSTing to page", the response status should actually be 401.
2B. If the entity-body contains the string "Request already reviewed", the
token has already been authorized and the response status should actually be
209.
2C. If the entity-body contains the string "Unable to identify application",
there is a client-side error and the response status should actually be 400.
2D. If the entity-body contains the string "What level of access", the token
has not been successfully authorized, and the response status should actually
be 400.
2E. Otherwise, if the entity-body does not contain the string "Almost
finished", I assume there has been a server-side error and change the status
code to 500.
Except for 1B and 2E, there's no reason why these operations shouldn't
return the proper response code. This will make launchpadlib much more
robust: right now the simulated browser can break because of trivial
wording changes to Launchpad.
** Affects: launchpad-foundations
Importance: Undecided
Status: New
** Affects: ubuntu
Importance: Undecided
Status: Invalid
** Also affects: launchpad-foundations
Importance: Undecided
Status: New
** Changed in: ubuntu
Status: New => Invalid
--
Launchpad should send appropriate error codes instead of 200 all the time
https://bugs.launchpad.net/bugs/461901
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs