Chromium Code Reviews| Index: util/net/http_transport.h |
| diff --git a/util/net/http_transport.h b/util/net/http_transport.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c4157a722ea068f5742424c2951aa014d7a97487 |
| --- /dev/null |
| +++ b/util/net/http_transport.h |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2014 The Crashpad Authors. All rights reserved. |
| +// |
| +// Licensed under the Apache License, Version 2.0 (the "License"); |
| +// you may not use this file except in compliance with the License. |
| +// You may obtain a copy of the License at |
| +// |
| +// http://www.apache.org/licenses/LICENSE-2.0 |
| +// |
| +// Unless required by applicable law or agreed to in writing, software |
| +// distributed under the License is distributed on an "AS IS" BASIS, |
| +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| +// See the License for the specific language governing permissions and |
| +// limitations under the License. |
| + |
| +#ifndef CRASHPAD_UTIL_NET_HTTP_TRANSPORT_H_ |
| +#define CRASHPAD_UTIL_NET_HTTP_TRANSPORT_H_ |
| + |
| +#include <stdint.h> |
|
Mark Mentovai
2014/10/30 21:13:54
Unused.
Robert Sesek
2014/10/31 14:48:14
Done.
|
| + |
| +#include <string> |
| + |
| +#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
|
| +#include "base/memory/scoped_ptr.h" |
| +#include "util/net/http_headers.h" |
| + |
| +namespace crashpad { |
| + |
| +class HTTPBodyStream; |
| + |
| +//! \brief HTTPTransport executes a HTTP request using the specified URL, HTTP |
| +//! method, headers, and body. This class can only issue a synchronous |
| +//! HTTP request. |
| +//! |
| +//! This class cannot be instantiated directly. A concrete subclass must be |
| +//! instantiated instead, which provides an implementation to execute the |
| +//! request that is appropriate for the host operating system. |
| +class HTTPTransport { |
| + public: |
| + virtual ~HTTPTransport(); |
| + |
| + //! \brief Sets URL to which the request will be made. |
| + //! \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.
|
| + 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.
|
| + |
| + //! \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.
|
| + //! \param[in] http_method The HTTP method. |
| + void SetMethod(const std::string& http_method); |
| + |
| + //! \brief Sets a HTTP header-value pair. |
| + //! \param[in] header The HTTP header name. Any previous value set at this |
| + //! name will be overwritten. |
| + //! \param[in] value The value to set for the header. |
| + 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
|
| + |
| + //! \brief Sets the stream object from which to generate the HTTP body. |
| + //! \param[in] stream A HTTPBodyStream, of which this class will take |
| + //! ownership. |
| + void SetBodyStream(scoped_ptr<HTTPBodyStream> stream); |
| + |
| + //! \brief Performs the HTTP request with the configured parameters and waits |
| + //! for the execution to complete. |
| + //! |
| + //! \return Whether or not the request was successful, defined as returning |
| + //! a HTTP status 200 (OK) code. |
| + 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.
|
| + |
| + protected: |
| + HTTPTransport(); |
| + |
| + const std::string& url() const { return url_; } |
| + const std::string& method() const { return method_; } |
| + const HTTPHeaders& headers() const { return headers_; } |
| + HTTPBodyStream* body_stream() const { return body_stream_.get(); } |
| + |
| + private: |
| + std::string url_; |
| + std::string method_; |
| + HTTPHeaders headers_; |
| + scoped_ptr<HTTPBodyStream> body_stream_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HTTPTransport); |
| +}; |
| + |
| +} // namespace crashpad |
| + |
| +#endif // CRASHPAD_UTIL_NET_HTTP_TRANSPORT_H_ |