OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/url_request/url_request_redirect_job.h" | 5 #include "net/url_request/url_request_redirect_job.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 int URLRequestRedirectJob::GetResponseCode() const { | 74 int URLRequestRedirectJob::GetResponseCode() const { |
75 // Should only be called after the URLRequest has been notified there's header | 75 // Should only be called after the URLRequest has been notified there's header |
76 // information. | 76 // information. |
77 DCHECK(fake_headers_.get()); | 77 DCHECK(fake_headers_.get()); |
78 return response_code_; | 78 return response_code_; |
79 } | 79 } |
80 | 80 |
81 URLRequestRedirectJob::~URLRequestRedirectJob() {} | 81 URLRequestRedirectJob::~URLRequestRedirectJob() {} |
82 | 82 |
83 void URLRequestRedirectJob::StartAsync() { | 83 void URLRequestRedirectJob::StartAsync() { |
84 // By this moment request might be already canceled and this job killed | |
85 if (!request_ || !request_->status().is_success()) | |
86 return; | |
mmenke
2015/07/13 21:14:17
Also, we should have a unit test for this. I don'
mmenke
2015/07/13 21:14:17
Instead of this, I think would be a little more co
alexanderk
2015/07/16 09:48:56
Well, it's kind of complicated to develop this uni
mmenke
2015/07/16 15:26:14
Thanks for catching this! This is a bug in the DC
mmenke
2015/07/16 17:58:32
Turns out this is actually a symptom of the bug yo
| |
87 | |
84 receive_headers_end_ = base::TimeTicks::Now(); | 88 receive_headers_end_ = base::TimeTicks::Now(); |
85 response_time_ = base::Time::Now(); | 89 response_time_ = base::Time::Now(); |
86 | 90 |
87 std::string header_string = | 91 std::string header_string = |
88 base::StringPrintf("HTTP/1.1 %i Internal Redirect\n" | 92 base::StringPrintf("HTTP/1.1 %i Internal Redirect\n" |
89 "Location: %s\n" | 93 "Location: %s\n" |
90 "Non-Authoritative-Reason: %s", | 94 "Non-Authoritative-Reason: %s", |
91 response_code_, | 95 response_code_, |
92 redirect_destination_.spec().c_str(), | 96 redirect_destination_.spec().c_str(), |
93 redirect_reason_.c_str()); | 97 redirect_reason_.c_str()); |
(...skipping 25 matching lines...) Expand all Loading... | |
119 base::Unretained(fake_headers_.get()))); | 123 base::Unretained(fake_headers_.get()))); |
120 | 124 |
121 // TODO(mmenke): Consider calling the NetworkDelegate with the headers here. | 125 // TODO(mmenke): Consider calling the NetworkDelegate with the headers here. |
122 // There's some weirdness about how to handle the case in which the delegate | 126 // There's some weirdness about how to handle the case in which the delegate |
123 // tries to modify the redirect location, in terms of how IsSafeRedirect | 127 // tries to modify the redirect location, in terms of how IsSafeRedirect |
124 // should behave, and whether the fragment should be copied. | 128 // should behave, and whether the fragment should be copied. |
125 URLRequestJob::NotifyHeadersComplete(); | 129 URLRequestJob::NotifyHeadersComplete(); |
126 } | 130 } |
127 | 131 |
128 } // namespace net | 132 } // namespace net |
OLD | NEW |