Merge lp:~mbp/bzr/http-messages into lp:bzr
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Martin Pool on 2010-10-11 | ||||
| Approved revision: | 4917 | ||||
| Merged at revision: | 5478 | ||||
| Proposed branch: | lp:~mbp/bzr/http-messages | ||||
| Merge into: | lp:bzr | ||||
| Diff against target: |
126 lines (+48/-5) 5 files modified
NEWS (+4/-0) bzrlib/tests/__init__.py (+1/-0) bzrlib/tests/test_transport.py (+12/-0) bzrlib/transport/http/__init__.py (+11/-0) bzrlib/transport/http/_pycurl.py (+20/-5) |
||||
| To merge this branch: | bzr merge lp:~mbp/bzr/http-messages | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| bzr-core | 2010-10-08 | Pending | |
|
Review via email:
|
|||
Commit Message
show http error body text with pycurl
Description of the Change
This, split out of <https:/
| Andrew Bennetts (spiv) wrote : | # |
| Martin Pool (mbp) wrote : | # |
On 8 October 2010 16:10, Andrew Bennetts <email address hidden> wrote:
>> This, split out of
>> <https:/
>> bzr print out a roughly readable version of the http error response body when
>> we get an error from pycurl. I found it useful interactively. I have not yet
>> added tests for it, except for a simple example doctest unit test. It would
>> be good to get some. I guess, because we really want to test we're dealing
>> properly with pycurl, we probably want to return an actual error from a tame
>> http server.
>
> I'm basically in favour, but I have a question: how does this react if the
> response body is very large? It's not uncommon for an error page to be many
> screenfuls of text (even with rudimentary HTML stripping). Overwhelming a
> terminal's scrollback so that bzr's error message is lost would be a regression.
> So I think it would be good to limit how much of a large body we display.
That's a good point. If it is very long, there's no great guarantee
that the readable part will be near the top rather than starting off
with masses of js or css. But even then it's probably better than
losing the bzr message altogether.
--
Martin
| Andrew Bennetts (spiv) wrote : | # |
> That's a good point. If it is very long, there's no great guarantee
> that the readable part will be near the top rather than starting off
> with masses of js or css. But even then it's probably better than
> losing the bzr message altogether.
Right. I forgot to mention but I raised this because we did encounter this
problem at some point in the past, so it definitely can happen.
I suppose the pedantic answer is to make sure we set (or don't) the Accept
header appropriately, and if the server insists on replying with text/html to
something that can't render it then there's not much we can reasonably do about
that, apart from "munge into something vaguely terminal friendly". Your patch +
limiting the output basically does that.
- 4916. By Martin Pool on 2010-10-08
-
Add test for unhtml_roughly, and truncate at 1000 bytes
| Martin Pool (mbp) wrote : | # |
It would be nice if http servers did send you a text/plain error message if you expressed a preference for that, but I wouldn't hold my breath. :)
This adds truncation and a test.
Is transport.http the most reasonable place for this? It's not exactly http but it is where we're likely to be given html without wanting it.
I'll see about adding something in test_http_
- 4917. By Martin Pool on 2010-10-08
-
resolve news
| Martin Pool (mbp) wrote : | # |
Now that, after <https:/
| Martin Pool (mbp) wrote : | # |
sent to pqm by email

> This, split out of /code.edge. launchpad. net/~mbp/ bzr/497274- http-405/ +merge/ 16229>, makes
> <https:/
> bzr print out a roughly readable version of the http error response body when
> we get an error from pycurl. I found it useful interactively. I have not yet
> added tests for it, except for a simple example doctest unit test. It would
> be good to get some. I guess, because we really want to test we're dealing
> properly with pycurl, we probably want to return an actual error from a tame
> http server.
I'm basically in favour, but I have a question: how does this react if the
response body is very large? It's not uncommon for an error page to be many
screenfuls of text (even with rudimentary HTML stripping). Overwhelming a
terminal's scrollback so that bzr's error message is lost would be a regression.
So I think it would be good to limit how much of a large body we display.