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

Issue 249031: Refactor HttpNetworkTransaction: Parse stream in HttpStream (Closed)

Created:
11 years, 2 months ago by vandebo (ex-Chrome)
Modified:
9 years, 7 months ago
Reviewers:
eroman, wtc
CC:
chromium-reviews_googlegroups.com, darin (slow to review), brettw, willchan no longer on Chromium, Paweł Hajdan Jr.
Visibility:
Public.

Description

Refactor HttpNetworkTransaction so that HttpStream is responsible for parsing the Http traffic. HttpBasicStream delegates parsing to HttpStreamParser in preparation for HttpPipelinedStream. BUG=13289 TEST=unittests Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=29316

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Patch Set 4 : '' #

Patch Set 5 : '' #

Total comments: 63

Patch Set 6 : '' #

Patch Set 7 : '' #

Patch Set 8 : '' #

Total comments: 40

Patch Set 9 : '' #

Patch Set 10 : '' #

Total comments: 54

Patch Set 11 : '' #

Total comments: 4

Patch Set 12 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1057 lines, -2371 lines) Patch
M net/http/http_basic_stream.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +31 lines, -13 lines 0 comments Download
A net/http/http_basic_stream.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +50 lines, -0 lines 0 comments Download
M net/http/http_network_transaction.h View 1 2 3 4 5 6 7 8 9 10 11 10 chunks +18 lines, -108 lines 0 comments Download
M net/http/http_network_transaction.cc View 1 2 3 4 5 6 7 8 9 10 11 36 chunks +184 lines, -451 lines 0 comments Download
M net/http/http_network_transaction_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +224 lines, -32 lines 0 comments Download
MM net/http/http_stream.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +51 lines, -28 lines 0 comments Download
A net/http/http_stream_parser.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +167 lines, -0 lines 0 comments Download
A + net/http/http_stream_parser.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +316 lines, -1739 lines 0 comments Download
M net/net.gyp View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -0 lines 0 comments Download
M net/socket/client_socket_handle.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +13 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (0 generated)
vandebo (ex-Chrome)
This change deserves more testing (testing suggestions welcome), but it passes unit tests and I'm ...
11 years, 2 months ago (2009-09-29 19:48:28 UTC) #1
eroman
> I know this is a large review, but I'm wondering how it's coming along. ...
11 years, 2 months ago (2009-10-05 19:43:51 UTC) #2
eroman
a couple initial nits http://codereview.chromium.org/249031/diff/8001/8018 File net/base/io_buffer.h (right): http://codereview.chromium.org/249031/diff/8001/8018#newcode85 Line 85: explicit StringIOBuffer(std::string s) const ...
11 years, 2 months ago (2009-10-05 21:08:43 UTC) #3
wtc
Some general comments first. Nit: When documenting member functions in a header, be consistent in ...
11 years, 2 months ago (2009-10-05 22:48:27 UTC) #4
vandebo (ex-Chrome)
All feedback integrated or responded to. wtc: wrt your general comment. I changed the superficial ...
11 years, 2 months ago (2009-10-06 21:08:34 UTC) #5
vandebo (ex-Chrome)
http://codereview.chromium.org/249031/diff/8001/8018 File net/base/io_buffer.h (right): http://codereview.chromium.org/249031/diff/8001/8018#newcode86 Line 86: : IOBuffer(static_cast<char*>(NULL)), On 2009/10/05 21:08:43, eroman wrote: > ...
11 years, 2 months ago (2009-10-06 22:23:01 UTC) #6
wtc
Steve, Sorry, I tried to review as much as I could, but this is a ...
11 years, 2 months ago (2009-10-09 02:22:38 UTC) #7
vandebo (ex-Chrome)
Response to your additional comments below. Any changes from the first round that I didn't ...
11 years, 2 months ago (2009-10-09 18:47:53 UTC) #8
wtc
You may want to consider moving the following files to a separate CL to make ...
11 years, 2 months ago (2009-10-09 21:41:25 UTC) #9
vandebo (ex-Chrome)
I separated the io buffer changes and the chunked encoder changes. Other comments addressed below. ...
11 years, 2 months ago (2009-10-09 23:54:01 UTC) #10
wtc
http://codereview.chromium.org/249031/diff/12001/5020 File net/http/http_stream_parser.h (right): http://codereview.chromium.org/249031/diff/12001/5020#newcode61 Line 61: STATE_PROCESSING_HEADERS, On 2009/10/09 23:54:01, vandebo wrote: > > ...
11 years, 2 months ago (2009-10-10 00:23:52 UTC) #11
wtc
LGTM. Sorry about the delay in reviewing this CL. Please check this in after making ...
11 years, 2 months ago (2009-10-13 22:47:36 UTC) #12
vandebo (ex-Chrome)
wtc, thank you for all the comments. I know this is a difficult CL to ...
11 years, 2 months ago (2009-10-15 04:54:02 UTC) #13
wtc
Steve, seems like you're waiting for my reply. Sorry about that. I've been very busy ...
11 years, 2 months ago (2009-10-16 00:51:50 UTC) #14
wtc
11 years, 2 months ago (2009-10-16 16:10:09 UTC) #15
LGTM.  Please check this in after fixing the nits below
without further review from me.

I reviewed the delta between Patch Sets 10 and 11.  There
are a lot of changes to http_stream_parser.cc, which I
just skimmed through.  (It's hard to review a large CL
carefully several times.  Sorry!)

Re: ERR_CONNECTION_CLOSED: I filed http://crbug.com/25032
on this issue.  The existing usage of ERR_CONNECTION_CLOSED
in SOCKS client sockets is for a real error -- it means the
underlying connection (below the SOCKS layer) was closed
unexpectedly.  It's a graceful connection closure in the
lower layer, but an abrupt connection closure in the
SOCKS layer, hence an error.  That is different from the
meaning of ERR_CONNECTION_CLOSED in this CL.

Let's follow up on ERR_CONNECTION_CLOSED in http://crbug.com/25032.

http://codereview.chromium.org/249031/diff/20001/14008
File net/http/http_network_transaction.cc (right):

http://codereview.chromium.org/249031/diff/20001/14008#newcode261
Line 261: // If there is a response body of known length, we need to drain it
first.
On 2009/10/15 04:54:02, vandebo wrote:
>
> > With our code, http_stream_->IsResponseBodyComplete()
> > should always return false at this point, if I'm not
> > mistaken.
> 
> I'm not sure about that.

This is because our code doesn't read the response
body after getting a 401 or 407 response; we
immediately start to handle the authentication
challenge.  The response body is left unread.
So unless the response body length is 0,
http_stream_->IsResponseBodyComplete() should
return false here.

In any case, this is a minor issue, and doing
the !http_stream_->IsResponseBodyComplete() test
here is harmless even if it's unnecessary.

http://codereview.chromium.org/249031/diff/20001/14009
File net/http/http_stream_parser.cc (right):

http://codereview.chromium.org/249031/diff/20001/14009#newcode488
Line 488: else if (response_body_length_ != -1)
On 2009/10/15 04:54:02, vandebo wrote:
>
> I can understand not using else return foo;  But 
> 
>   if (foo)
>     return x;
>   else if (bar)
>     return y;
> 
> is different - it provides information to future code readers about the
> relationship of the two conditionals - that the order you check them in is
> important.

You can write that like this:

  if (foo)
    return x;
  if (bar)
    return y;

http://codereview.chromium.org/249031/diff/18010/18011
File net/http/http_stream.h (right):

http://codereview.chromium.org/249031/diff/18010/18011#newcode47
Line 47: // headers are filled into the HttpRequestInfo passed into SendRequest.
This comment is wrong.

SendRequest takes a const HttpRequestInfo* request argument.
How do we fill responder headers into a const HttpRequestInfo?
Also, HttpRequestInfo doesn't have a response headers field.

I think this comment should read:

  The response headers are filled into the HttpResponseInfo
  returned by GetResponseInfo.

Or just delete this comment.

http://codereview.chromium.org/249031/diff/18010/18017
File net/http/http_stream_parser.cc (right):

http://codereview.chromium.org/249031/diff/18010/18017#newcode58
Line 58: return result;
Nit: you can also just do
  return result > 0 : OK : result;

We use that expression elsewhere.  I leave this up to you...

http://codereview.chromium.org/249031/diff/18010/18017#newcode367
Line 367: // some left over in |user_read_buf|, plus there may be more
Typo: user_read_buf => user_read_buf_
      user_buf => user_buf_

Two occurrences of each in this comment block.

http://codereview.chromium.org/249031/diff/18010/18018
File net/http/http_stream_parser.h (right):

http://codereview.chromium.org/249031/diff/18010/18018#newcode26
Line 26: // |read_buffer|.  The offset in |read_buffer| indicates valid data.
"The offset in |read_buffer| indicates valid data."

Does this refer to the offset before or after parsing the
stream?

Does the offset indicates the beginning of the end of
valid data?

Powered by Google App Engine
This is Rietveld 408576698