CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
http_web_request.h
1
2#pragma once
3
4#include <cstdint>
5#include <system/async_callback.h>
6#include <system/object.h>
7#include <system/shared_ptr.h>
8#include <system/string.h>
9#include <system/uri.h>
10#include <net/cookie_container.h>
11#include <net/http/http_response_message.h>
12#include <net/iweb_proxy.h>
13#include <net/service_point.h>
14#include <net/web_request.h>
15#include "security/cryptography/x509_certificates/x509_certificate_collection.h"
16
17namespace System { namespace Net {
18
19namespace Http {
20 class HttpResponseMessage;
21}
22
23class RequestStream;
24
29class ASPOSECPP_SHARED_CLASS HttpWebRequest : public System::Net::WebRequest
30{
35
37 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
39 ASPOSECPP_SHARED_RTTI_INFO_DECL();
40
41public:
44 ASPOSECPP_SHARED_API void set_ProtocolVersion(System::Version version);
46 ASPOSECPP_SHARED_API void set_Timeout(int timeout) override;
48 ASPOSECPP_SHARED_API void set_PreAuthenticate(bool value) override;
51 ASPOSECPP_SHARED_API void set_ContentLength(int64_t length) override;
52
55 ASPOSECPP_SHARED_API String get_Accept();
58 ASPOSECPP_SHARED_API void set_Accept(String value);
61 ASPOSECPP_SHARED_API virtual bool get_AllowReadStreamBuffering();
64 ASPOSECPP_SHARED_API virtual void set_AllowReadStreamBuffering(bool value);
66 ASPOSECPP_SHARED_API String get_ContentType() override;
68 ASPOSECPP_SHARED_API void set_ContentType(String value) override;
71 ASPOSECPP_SHARED_API int32_t get_ContinueTimeout();
74 ASPOSECPP_SHARED_API void set_ContinueTimeout(int32_t value);
82 ASPOSECPP_SHARED_API System::SharedPtr<ICredentials> get_Credentials() override;
84 ASPOSECPP_SHARED_API void set_Credentials(System::SharedPtr<ICredentials> value) override;
87 ASPOSECPP_SHARED_API virtual bool get_HaveResponse();
89 ASPOSECPP_SHARED_API System::SharedPtr<WebHeaderCollection> get_Headers() override;
91 ASPOSECPP_SHARED_API void set_Headers(System::SharedPtr<WebHeaderCollection> value) override;
93 ASPOSECPP_SHARED_API String get_Method() override;
95 ASPOSECPP_SHARED_API void set_Method(String value) override;
97 ASPOSECPP_SHARED_API System::SharedPtr<Uri> get_RequestUri() override;
100 ASPOSECPP_SHARED_API virtual bool get_SupportsCookieContainer();
102 ASPOSECPP_SHARED_API bool get_UseDefaultCredentials() override;
104 ASPOSECPP_SHARED_API void set_UseDefaultCredentials(bool value) override;
106 ASPOSECPP_SHARED_API System::SharedPtr<IWebProxy> get_Proxy() override;
108 ASPOSECPP_SHARED_API void set_Proxy(System::SharedPtr<IWebProxy> value) override;
109
113
116 ASPOSECPP_SHARED_API virtual bool get_AllowAutoRedirect();
119 ASPOSECPP_SHARED_API virtual void set_AllowAutoRedirect(bool value);
120
123 ASPOSECPP_SHARED_API virtual int get_MaximumAutomaticRedirections();
126 ASPOSECPP_SHARED_API virtual void set_MaximumAutomaticRedirections(int value);
127
130 ASPOSECPP_SHARED_API HttpWebRequest(System::SharedPtr<Uri> uri);
132 ASPOSECPP_SHARED_API System::SharedPtr<WebResponse> GetResponse() override;
134 ASPOSECPP_SHARED_API void Abort() override;
139 System::SharedPtr<Object> state) override;
141 ASPOSECPP_SHARED_API System::SharedPtr<IO::Stream>
145 System::SharedPtr<Object> state) override;
147 ASPOSECPP_SHARED_API System::SharedPtr<WebResponse>
149
152 ASPOSECPP_SHARED_API virtual bool get_SendChunked();
155 ASPOSECPP_SHARED_API virtual void set_SendChunked(bool value);
158 ASPOSECPP_SHARED_API virtual bool get_AllowWriteStreamBuffering();
161 ASPOSECPP_SHARED_API virtual void set_AllowWriteStreamBuffering(bool value);
164 ASPOSECPP_SHARED_API virtual bool get_KeepAlive();
167 ASPOSECPP_SHARED_API virtual void set_KeepAlive(bool value);
170 ASPOSECPP_SHARED_API virtual System::SharedPtr<
175 ASPOSECPP_SHARED_API virtual void set_ClientCertificates(
179 ASPOSECPP_SHARED_API virtual System::String get_UserAgent();
182 ASPOSECPP_SHARED_API virtual void set_UserAgent(System::String value);
184 ASPOSECPP_SHARED_API int64_t get_ContentLength() override;
186 ASPOSECPP_SHARED_API bool get_PreAuthenticate() override;
188 ASPOSECPP_SHARED_API int32_t get_Timeout() override;
191 ASPOSECPP_SHARED_API virtual void AddRange(int32_t range);
196 ASPOSECPP_SHARED_API virtual void AddRange(System::String rangeSpecifier, int32_t from, int32_t to);
197
200 ASPOSECPP_SHARED_API virtual System::String get_Referer();
203 ASPOSECPP_SHARED_API virtual void set_Referer(System::String value);
204
206 ASPOSECPP_SHARED_API System::String get_ConnectionGroupName() override;
208 ASPOSECPP_SHARED_API void set_ConnectionGroupName(System::String value) override;
209
210protected:
211#ifdef ASPOSE_GET_SHARED_MEMBERS
213 void GetSharedMembers(System::Object::shared_members_type& result) const override;
214#endif
215private:
217 static const int32_t DefaultContinueTimeout;
219 System::SharedPtr<WebHeaderCollection> _webHeaderCollection;
221 System::SharedPtr<Uri> _requestUri;
223 String _originVerb;
225 int32_t _continueTimeout;
227 bool _allowReadStreamBuffering;
236 int32_t _beginGetRequestStreamCalled;
239 int32_t _beginGetResponseCalled;
242 int32_t _endGetRequestStreamCalled;
245 int32_t _endGetResponseCalled;
250 AsyncCallback _requestStreamCallback;
253 AsyncCallback _responseCallback;
256 int32_t _abortCalled;
258 int64_t _contentLength;
260 bool _isVersionHttp10;
262 int32_t _timeout;
264 bool m_PreAuthenticate;
265
269 bool get_RequestSubmitted();
270
273 static const System::ArrayPtr<String>& WellKnownContentHeaders();
274
278 void SetSpecialHeaders(String HeaderName, String value);
281 void CheckAbort();
285 bool IsWellKnownContentHeader(String header);
286
288 String _connectionGroupName;
290 bool _allowAutoRedirect = true;
292 int _maximumAutomaticRedirections = 50;
294 bool _keepAlive;
296 String _userAgent;
297
303 SharedPtr<Http::HttpResponseMessage> DoRequest(const SharedPtr<Uri>& requestUri,
304 const String& verb, bool useCredentials=true);
305};
306
307}} // namespace System::Net
Represents the HTTP web request. Objects of this class should only be allocated using System::MakeObj...
Definition: http_web_request.h:30
System::SharedPtr< System::IO::Stream > GetRequestStream() override
Returns the stream for writing data to the resource.
bool get_UseDefaultCredentials() override
Gets a value that indicates if the 'Credential' property is equal to the 'DefaultCredentials' propert...
System::SharedPtr< IAsyncResult > BeginGetRequestStream(AsyncCallback callback, System::SharedPtr< Object > state) override
Initiates an asynchronous operation to get a stream for writing data to the resource.
virtual void set_ClientCertificates(System::SharedPtr< System::Security::Cryptography::X509Certificates::X509CertificateCollection > value)
Sets the collection of the certificates that are associated with the current request.
virtual bool get_SendChunked()
Gets a value that indicates if data must be sent in segments.
int32_t get_ContinueTimeout()
Gets a timeout to wait until the 100-Continue status code is received.
virtual bool get_AllowAutoRedirect()
Gets a value that indicates if the request should follow redirections.
virtual System::SharedPtr< System::Security::Cryptography::X509Certificates::X509CertificateCollection > get_ClientCertificates()
Gets the collection of the certificates that are associated with the current request.
void set_ProtocolVersion(System::Version version)
Sets the version of the HTTP.
virtual void set_CookieContainer(System::SharedPtr< System::Net::CookieContainer > value)
Sets a cookie container associated with the current web request.
void set_ContentLength(int64_t length) override
Sets the number of bytes of the request data to sent.
void Abort() override
Aborts the current request.
virtual void AddRange(System::String rangeSpecifier, int32_t from, int32_t to)
Adds the 'Range' header to the current request.
bool get_PreAuthenticate() override
Gets a value that indicates if the request must be pre-authenticated.
System::SharedPtr< WebHeaderCollection > get_Headers() override
Gets the collection of the HTTP headers.
virtual void set_SendChunked(bool value)
Sets a value that indicates if data must be sent in segments.
void set_Timeout(int timeout) override
Sets an amount of time in milliseconds after which the request will be timed out.
virtual void set_AllowWriteStreamBuffering(bool value)
Sets a value that indicates if buffering is enabled for sending data.
virtual bool get_SupportsCookieContainer()
Returns a value that indicates if the current request can use a cookie container.
System::SharedPtr< IO::Stream > EndGetRequestStream(System::SharedPtr< IAsyncResult > asyncResult) override
Waits until the specified asynchronous operation to get a stream completes.
virtual bool get_AllowWriteStreamBuffering()
Gets a value that indicates if buffering is enabled for sending data.
void set_ContentType(String value) override
Sets the MIME type of the request.
HttpWebRequest(System::SharedPtr< Uri > uri)
Constructs a new instance.
int64_t get_ContentLength() override
Gets the number of bytes of the request data to sent.
System::SharedPtr< ServicePoint > get_ServicePoint()
Returns a service point that represents the network connection to the resource.
String get_ContentType() override
Gets the MIME type of the request.
void set_ContinueTimeout(int32_t value)
Sets a timeout to wait until the 100-Continue status code is received.
void set_PreAuthenticate(bool value) override
Sets a value that indicates if the request must be pre-authenticated.
virtual bool get_KeepAlive()
Gets a value that indicates if the current request must contain the 'Keep-Alive' header.
virtual System::String get_UserAgent()
Gets a value of the 'User-Agent' header.
virtual void AddRange(int32_t range)
Adds the 'Range' header to the current request.
void set_ConnectionGroupName(System::String value) override
Sets the name of the connection group.
void set_Accept(String value)
Sets the 'Accept' HTTP header value.
virtual System::String get_Referer()
Gets a value of the 'Referer' header.
System::SharedPtr< Uri > get_RequestUri() override
Returns the request URI.
virtual void set_Referer(System::String value)
Sets a value of the 'Referer' header.
virtual void set_AllowAutoRedirect(bool value)
Sets a value that indicates if the request should follow redirections.
void set_Proxy(System::SharedPtr< IWebProxy > value) override
Sets the HTTP proxy.
void set_Method(String value) override
Sets the HTTP method.
virtual void set_UserAgent(System::String value)
Sets a value of the 'User-Agent' header.
virtual bool get_HaveResponse()
Returns a value that indicates if a response is received.
String get_Method() override
Gets the HTTP method.
virtual void set_AllowReadStreamBuffering(bool value)
Sets a value indicates if the data received from the resource must be buffered.
virtual int get_MaximumAutomaticRedirections()
Gets a maximum number of allowed redirections.
System::String get_ConnectionGroupName() override
Gets the name of the connection group.
System::SharedPtr< IAsyncResult > BeginGetResponse(AsyncCallback callback, System::SharedPtr< Object > state) override
Initiates an asynchronous request for the resource.
System::SharedPtr< ICredentials > get_Credentials() override
Gets authentication information that is associated with the current request.
virtual System::SharedPtr< System::Net::CookieContainer > get_CookieContainer()
Gets a cookie container associated with the current web request.
virtual void set_KeepAlive(bool value)
Sets a value that indicates if the current request must contain the 'Keep-Alive' header.
String get_Accept()
Gets the 'Accept' HTTP header value.
void set_Credentials(System::SharedPtr< ICredentials > value) override
Sets authentication information that is associated with the current request.
void set_UseDefaultCredentials(bool value) override
Sets a value that indicates if the 'Credential' property is equal to the 'DefaultCredentials' propert...
System::SharedPtr< WebResponse > EndGetResponse(System::SharedPtr< IAsyncResult > asyncResult) override
Waits until the specified asynchronous request for the resource completes.
virtual void set_MaximumAutomaticRedirections(int value)
Sets a maximum number of allowed redirections.
System::SharedPtr< IWebProxy > get_Proxy() override
Gets the HTTP proxy.
virtual bool get_AllowReadStreamBuffering()
Gets a value indicates if the data received from the resource must be buffered.
int32_t get_Timeout() override
Gets an amount of time in milliseconds after which the request will be timed out.
System::SharedPtr< WebResponse > GetResponse() override
Returns the web response associated with the current web request.
void set_Headers(System::SharedPtr< WebHeaderCollection > value) override
Sets the collection of the HTTP headers.
Represents a web request. Objects of this class should only be allocated using System::MakeObject() f...
Definition: web_request.h:31
Collection of X509 certificate objects. Objects of this class should only be allocated using System::...
Definition: x509_certificate_collection.h:19
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 version number. This type should be allocated on stack and passed to functions by value ...
Definition: version.h:15
Definition: db_command.h:9
System::MulticastDelegate< void(SharedPtr< IAsyncResult >)> AsyncCallback
A delegate type that represents a method to be called when asynchronous operation completes.
Definition: async_callback.h:13