1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_URL_REQUEST_URL_REQUEST_REDIRECT_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_REDIRECT_JOB_H_
10 #include "base/memory/weak_ptr.h"
11 #include "net/base/net_export.h"
12 #include "net/url_request/url_request_job.h"
18 // A URLRequestJob that will redirect the request to the specified
19 // URL. This is useful to restart a request at a different URL based
20 // on the result of another job.
21 class NET_EXPORT URLRequestRedirectJob : public URLRequestJob {
23 // Valid status codes for the redirect job. Other 30x codes are theoretically
24 // valid, but unused so far. Both 302 and 307 are temporary redirects, with
25 // the difference being that 302 converts POSTs to GETs and removes upload
28 REDIRECT_302_FOUND = 302,
29 REDIRECT_307_TEMPORARY_REDIRECT = 307,
32 // Constructs a job that redirects to the specified URL. |redirect_reason| is
33 // logged for debugging purposes, and must not be an empty string.
34 URLRequestRedirectJob(URLRequest* request,
35 NetworkDelegate* network_delegate,
36 const GURL& redirect_destination,
37 StatusCode http_status_code,
38 const std::string& redirect_reason);
40 virtual void Start() OVERRIDE;
41 virtual bool IsRedirectResponse(GURL* location,
42 int* http_status_code) OVERRIDE;
43 virtual bool CopyFragmentOnRedirect(const GURL& location) const OVERRIDE;
45 virtual void GetLoadTimingInfo(
46 LoadTimingInfo* load_timing_info) const OVERRIDE;
49 virtual ~URLRequestRedirectJob();
53 const GURL redirect_destination_;
54 const int http_status_code_;
55 base::TimeTicks receive_headers_end_;
56 std::string redirect_reason_;
58 base::WeakPtrFactory<URLRequestRedirectJob> weak_factory_;
63 #endif // NET_URL_REQUEST_URL_REQUEST_REDIRECT_JOB_H_