CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
http_client.h
1
2#pragma once
3
4#include <functional>
5#include <system/globalization/culture_info.h>
6#include <system/io/stream.h>
7#include <system/shared_ptr.h>
8#include <system/timespan.h>
9
10#include <net/http/headers/http_request_headers.h>
11#include <net/http/http_completion_option.h>
12#include <net/http/http_content.h>
13#include <net/http/http_message_handler.h>
14#include <net/http/http_message_invoker.h>
15#include <net/http/http_request_message.h>
16#include <net/http/http_response_message.h>
17#include <net/http_request_exception.h>
18
19namespace System { namespace Net { namespace Http {
20
25class ASPOSECPP_SHARED_CLASS HttpClient : public System::Net::Http::HttpMessageInvoker
26{
28 typedef HttpClient ThisType;
31
33 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
35 ASPOSECPP_SHARED_RTTI_INFO_DECL();
36
37public:
46 ASPOSECPP_SHARED_API void set_BaseAddress(System::SharedPtr<Uri> value);
49 ASPOSECPP_SHARED_API TimeSpan get_Timeout();
52 ASPOSECPP_SHARED_API void set_Timeout(TimeSpan value);
55 ASPOSECPP_SHARED_API int64_t get_MaxResponseContentBufferSize();
58 ASPOSECPP_SHARED_API void set_MaxResponseContentBufferSize(int64_t value);
59
61 ASPOSECPP_SHARED_API HttpClient();
68 ASPOSECPP_SHARED_API HttpClient(System::SharedPtr<HttpMessageHandler> handler, bool disposeHandler);
69
71 ASPOSECPP_SHARED_API void CancelPendingRequests();
72
77 HttpCompletionOption completionOption);
78
79protected:
81 void Dispose(bool disposing) override;
82
83private:
85 static TimeSpan s_defaultTimeout;
87 static TimeSpan s_maxTimeout;
89 static TimeSpan s_infiniteTimeout;
91 static const HttpCompletionOption defaultCompletionOption;
93 bool _operationStarted;
95 bool _disposed;
99 System::SharedPtr<Uri> _baseAddress;
101 TimeSpan _timeout;
103 int64_t _maxResponseContentBufferSize;
104
107 void DisposeRequestContent(System::SharedPtr<HttpRequestMessage> request);
109 void SetOperationStarted();
112 void CheckDisposedOrStarted();
115 void CheckDisposed();
119 static void CheckRequestMessage(System::SharedPtr<HttpRequestMessage> request);
122 void PrepareRequestMessage(System::SharedPtr<HttpRequestMessage> request);
128 static void CheckBaseAddress(System::SharedPtr<Uri> baseAddress, String parameterName);
131 System::SharedPtr<Uri> CreateUri(String uri);
132
134 static struct __StaticConstructor__
135 {
136 __StaticConstructor__();
137 } s_constructor__;
138};
139
140}}} // namespace System::Net::Http
Represents a base class of an HTTP client for sending requests and receiving responses....
Definition: http_client.h:26
void CancelPendingRequests()
Cancels all pending requests.
System::SharedPtr< HttpResponseMessage > Send(System::SharedPtr< HttpRequestMessage > request, HttpCompletionOption completionOption)
Sends the specified HTTP request.
HttpClient()
Constructs a new instance.
void set_BaseAddress(System::SharedPtr< Uri > value)
Sets the base address of the resource that is used for sending requests.
TimeSpan get_Timeout()
Gets the timespan to wait before the request times out.
int64_t get_MaxResponseContentBufferSize()
Gets the maximum number of bytes of response content.
System::SharedPtr< Uri > get_BaseAddress()
Gets the base address of the resource that is used for sending requests.
void Dispose(bool disposing) override
Disposes the current instance. This method also disposes the handler if required.
HttpClient(System::SharedPtr< HttpMessageHandler > handler, bool disposeHandler)
Constructs a new instance.
void set_MaxResponseContentBufferSize(int64_t value)
Sets the maximum number of bytes of response content.
void set_Timeout(TimeSpan value)
Sets the timespan to wait before the request times out.
System::SharedPtr< Headers::HttpRequestHeaders > get_DefaultRequestHeaders()
Gets the headers sent with each request.
HttpClient(System::SharedPtr< HttpMessageHandler > handler)
Constructs a new instance.
Allows applications to call the Send method on an HTTP handler chain. Objects of this class should on...
Definition: http_message_invoker.h:16
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a time interval. This type should be allocated on stack and passed to functions by value o...
Definition: timespan.h:59
HttpCompletionOption
Indicates when an HttpClient operation should be completed.
Definition: http_completion_option.h:8
Definition: db_command.h:9