CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
web_header_collection.h
1
2#pragma once
3
4#include <cstdint>
5#include <system/array.h>
6#include <system/collections/dictionary.h>
7#include <system/collections/list.h>
8#include <system/string.h>
9
10#include <net/http_request_header.h>
11#include <net/http_response_header.h>
12
13namespace System { namespace Net {
14
16enum class WebHeaderCollectionType : uint8_t
17{
19 Unknown,
24};
25
30class ASPOSECPP_SHARED_CLASS WebHeaderCollection : public Object
31{
32public:
36 ASPOSECPP_SHARED_API void Add(String header, String value);
40 ASPOSECPP_SHARED_API void Add(HttpResponseHeader header, String value);
44 ASPOSECPP_SHARED_API void Add(HttpRequestHeader header, String value);
48 ASPOSECPP_SHARED_API String idx_get(HttpRequestHeader header);
52 ASPOSECPP_SHARED_API void idx_set(HttpRequestHeader header, String value);
56 ASPOSECPP_SHARED_API String idx_get(HttpResponseHeader header);
60 ASPOSECPP_SHARED_API void idx_set(HttpResponseHeader header, String value);
64 ASPOSECPP_SHARED_API String idx_get(String name);
68 ASPOSECPP_SHARED_API void idx_set(String name, String value);
71 ASPOSECPP_SHARED_API void Remove(String name);
74 ASPOSECPP_SHARED_API void Remove(HttpResponseHeader header);
77 ASPOSECPP_SHARED_API void Remove(HttpRequestHeader header);
79 ASPOSECPP_SHARED_API String ToString() const override;
80
82 ASPOSECPP_SHARED_API WebHeaderCollection();
83
86 ASPOSECPP_SHARED_API int32_t get_Count() const;
89 ASPOSECPP_SHARED_API System::ArrayPtr<String> AllKeys();
92 ASPOSECPP_SHARED_API System::ArrayPtr<String> get_Keys();
93
97 ASPOSECPP_SHARED_API String GetKey(int index);
102
106 ASPOSECPP_SHARED_API void Set(String name, String value);
107
111 ASPOSECPP_SHARED_API static bool IsRestricted(const String& headerName);
112
113protected:
115 ASPOSECPP_SHARED_API ~WebHeaderCollection() override;
116
117private:
119 static const int32_t ApproxAveHeaderLineSize;
121 static const int32_t ApproxHighAvgNumHeaders;
130
133 bool get_AllowHttpRequestHeader();
136 bool get_AllowHttpResponseHeader();
137
139 static System::ArrayPtr<char16_t> s_httpTrimCharacters;
140
145 static String CheckBadHeaderValueChars(String value);
150 static String CheckBadHeaderNameChars(String name);
154 static bool ContainsNonAsciiChars(String token);
157 bool IsInitialized();
159 void EnsureInitialized();
161 void InvalidateCachedArray();
166
168 static struct __StaticConstructor__
169 {
170 __StaticConstructor__();
171 } s_constructor__;
172};
173
174}} // namespace System::Net
List forward declaration.
Definition: list.h:127
Represents the collection of the protocol headers. Objects of this class should only be allocated usi...
Definition: web_header_collection.h:31
void Set(String name, String value)
Sets the value of the specified header.
void Remove(String name)
Removes the header by the specified header name.
void idx_set(HttpResponseHeader header, String value)
Sets the header value using the specified response's header.
String ToString() const override
Analog of C# Object.ToString() method. Enables converting custom objects to string.
String GetKey(int index)
Returns a key at the specified index.
String idx_get(String name)
Gets the header value using the specified header name.
void Remove(HttpRequestHeader header)
Removes the specified request's header.
void Add(String header, String value)
Adds the specified pair of the header name and the header value to the collection.
void Add(HttpResponseHeader header, String value)
Adds the specified pair of the header and the header value to the collection.
System::ArrayPtr< String > get_Keys()
Returns a collection of header names that are stored in the collection.
~WebHeaderCollection() override
Destructs the current instance.
WebHeaderCollection()
Constructs a new instance.
String idx_get(HttpResponseHeader header)
Gets the header value using the specified response's header.
System::ArrayPtr< String > AllKeys()
Returns a collection of header names that are stored in the collection.
System::ArrayPtr< System::String > GetValues(String header)
Returns the collection of the header values.
void idx_set(String name, String value)
Sets the header value using the specified header name.
int32_t get_Count() const
Returns a number of elements in the collection.
String idx_get(HttpRequestHeader header)
Gets the header value using the specified request's header.
void Remove(HttpResponseHeader header)
Removes the specified response's header.
void Add(HttpRequestHeader header, String value)
Adds the specified pair of the header and the header value to the collection.
void idx_set(HttpRequestHeader header, String value)
Sets the header value of the specified header.
static bool IsRestricted(const String &headerName)
Tests whether the specified HTTP header can be set for the request.
Represents a web request. Objects of this class should only be allocated using System::MakeObject() f...
Definition: web_request.h:31
Represents a web response. Objects of this class should only be allocated using System::MakeObject() ...
Definition: web_response.h:20
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
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
HttpResponseHeader
Enumerates the http response headers.
Definition: http_response_header.h:12
HttpRequestHeader
Enumerates the request headers.
Definition: http_request_header.h:12
WebHeaderCollectionType
Enumerates the types of the protocol headers collection.
Definition: web_header_collection.h:17
Definition: db_command.h:9