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

Side by Side Diff: util/net/http_transport.h

Issue 692963002: Add HTTPTransport, a Mac implementation, and an end-to-end test. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_UTIL_NET_HTTP_TRANSPORT_H_
16 #define CRASHPAD_UTIL_NET_HTTP_TRANSPORT_H_
17
18 #include <stdint.h>
Mark Mentovai 2014/10/30 21:13:54 Unused.
Robert Sesek 2014/10/31 14:48:14 Done.
19
20 #include <string>
21
22 #include "base/compiler_specific.h"
Mark Mentovai 2014/10/30 21:13:54 You don’t need this, but you do need base/basictyp
Robert Sesek 2014/10/31 14:48:14 I get these confused, esp. because this has moved
23 #include "base/memory/scoped_ptr.h"
24 #include "util/net/http_headers.h"
25
26 namespace crashpad {
27
28 class HTTPBodyStream;
29
30 //! \brief HTTPTransport executes a HTTP request using the specified URL, HTTP
31 //! method, headers, and body. This class can only issue a synchronous
32 //! HTTP request.
33 //!
34 //! This class cannot be instantiated directly. A concrete subclass must be
35 //! instantiated instead, which provides an implementation to execute the
36 //! request that is appropriate for the host operating system.
37 class HTTPTransport {
38 public:
39 virtual ~HTTPTransport();
40
41 //! \brief Sets URL to which the request will be made.
42 //! \param[in] url The request URL.
Mark Mentovai 2014/10/30 21:13:54 I’ve been putting a blank //! line between section
Robert Sesek 2014/10/31 14:48:14 Done.
43 void SetURL(const std::string& url);
Mark Mentovai 2014/10/30 21:13:54 I’d consider it OK to inline these nonvirtual sett
Robert Sesek 2014/10/31 14:48:14 Acknowledged.
44
45 //! \brief Sets the HTTP method to execute. E.g., GET, POST, etc.
Mark Mentovai 2014/10/30 21:13:54 Is there a default method if nobody calls this?
Robert Sesek 2014/10/31 14:48:14 Done.
46 //! \param[in] http_method The HTTP method.
47 void SetMethod(const std::string& http_method);
48
49 //! \brief Sets a HTTP header-value pair.
50 //! \param[in] header The HTTP header name. Any previous value set at this
51 //! name will be overwritten.
52 //! \param[in] value The value to set for the header.
53 void SetHeader(const std::string& header, const std::string& value);
Mark Mentovai 2014/10/30 21:13:54 Maybe AddHeader()?
Robert Sesek 2014/10/31 14:48:14 I chose Set deliberately since this isn't additive
54
55 //! \brief Sets the stream object from which to generate the HTTP body.
56 //! \param[in] stream A HTTPBodyStream, of which this class will take
57 //! ownership.
58 void SetBodyStream(scoped_ptr<HTTPBodyStream> stream);
59
60 //! \brief Performs the HTTP request with the configured parameters and waits
61 //! for the execution to complete.
62 //!
63 //! \return Whether or not the request was successful, defined as returning
64 //! a HTTP status 200 (OK) code.
65 virtual bool ExecuteSynchronously() = 0;
Mark Mentovai 2014/10/30 21:13:54 I think we will want a way to get the response hea
Robert Sesek 2014/10/31 14:48:14 Acknowledged.
66
67 protected:
68 HTTPTransport();
69
70 const std::string& url() const { return url_; }
71 const std::string& method() const { return method_; }
72 const HTTPHeaders& headers() const { return headers_; }
73 HTTPBodyStream* body_stream() const { return body_stream_.get(); }
74
75 private:
76 std::string url_;
77 std::string method_;
78 HTTPHeaders headers_;
79 scoped_ptr<HTTPBodyStream> body_stream_;
80
81 DISALLOW_COPY_AND_ASSIGN(HTTPTransport);
82 };
83
84 } // namespace crashpad
85
86 #endif // CRASHPAD_UTIL_NET_HTTP_TRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698