Represents an HTTP response, encapsulating the protocol, status, headers, cookies, and body of the response.
More...
|
| HttpResponse () |
| Initializes a new instance of the HttpResponse class.
|
|
HttpResponse(StatusCode status, string protocol=Constance.DefaultHttpProtocol) Tuple< string, string > | GetHeader (int i) |
| Initializes a new instance of the HttpResponse class with the specified status and protocol.
|
|
string | GetHeader (string key) |
| Gets the value of the specified header.
|
|
Tuple< string, string > | GetCookie (int i) |
| Gets the cookie at the specified index.
|
|
string | GetCookie (string name) |
| Gets the value of the specified cookie.
|
|
void | Clear () |
| Clears the current response, resetting all properties.
|
|
HttpResponse | SetBegin (StatusCode status, string protocol=Constance.DefaultHttpProtocol) |
| Sets the beginning of the response with the specified status and protocol.
|
|
HttpResponse | SetContentType (string extension) |
| Sets the Content-Type header for the response based on the file extension.
|
|
HttpResponse | SetHeader (string key, string value) |
| Sets a header with the specified key and value.
|
|
HttpResponse | SetCookie (string name, string value, int maxAge=86400, string path="", string domain="", bool secure=true, bool strict=true, bool httpOnly=true) |
| Sets a cookie with the specified name, value, and optional parameters.
|
|
HttpResponse | SetBody (string body="") |
| Sets the body of the response with the specified string content.
|
|
HttpResponse | SetBody (byte[] body) |
| Sets the body of the response with the specified byte array content.
|
|
bool | IsPendingHeader () |
| Indicates whether the response is pending header processing.
|
|
bool | IsPendingBody () |
| Indicates whether the response is pending body processing.
|
|
bool | SetHeaderBuffer (byte[] buffer, int position, int length) |
| Sets the header buffer with the specified byte array data.
|
|
bool | SetBodyBuffer (byte[] buffer, int position, int length) |
| Sets the body buffer with the specified byte array data.
|
|
|
string | Protocol [get] |
| Gets the HTTP protocol used in the response.
|
|
long | HeaderCount [get] |
| Gets the count of headers in the response.
|
|
int | CookieCount [get] |
| Gets the count of cookies in the response.
|
|
IMemoryBuffer | Cache [get] |
| Gets the memory buffer that stores the response data.
|
|
bool | IsEmpty [get] |
| Indicates whether the response body is empty.
|
|
bool | IsErrorSet [get] |
| Indicates whether an error has been set in the response.
|
|
StatusCode | Status [get] |
| Gets the HTTP status code of the response.
|
|
string | BodyAsString [get] |
| Gets the body of the response as a string.
|
|
byte[] | BodyAsBytes [get] |
| Gets the body of the response as a byte array.
|
|
Represents an HTTP response, encapsulating the protocol, status, headers, cookies, and body of the response.
◆ GetCookie() [1/2]
Tuple< string, string > XmobiTea.ProtonNetCommon.HttpResponse.GetCookie |
( |
int | i | ) |
|
Gets the cookie at the specified index.
- Parameters
-
i | The index of the cookie. |
- Returns
- A tuple containing the cookie name and value.
◆ GetCookie() [2/2]
string XmobiTea.ProtonNetCommon.HttpResponse.GetCookie |
( |
string | name | ) |
|
Gets the value of the specified cookie.
- Parameters
-
name | The name of the cookie. |
- Returns
- The value of the cookie, or null if not found.
◆ GetHeader() [1/2]
HttpResponse(StatusCode status, string protocol=Constance.DefaultHttpProtocol) Tuple< string, string > XmobiTea.ProtonNetCommon.HttpResponse.GetHeader |
( |
int | i | ) |
|
Initializes a new instance of the HttpResponse class with the specified status and protocol.
- Parameters
-
status | The HTTP status code. |
protocol | The HTTP protocol (default is Constance.DefaultHttpProtocol). |
Gets the header at the specified index.
- Parameters
-
i | The index of the header. |
- Returns
- A tuple containing the header name and value.
◆ GetHeader() [2/2]
string XmobiTea.ProtonNetCommon.HttpResponse.GetHeader |
( |
string | key | ) |
|
Gets the value of the specified header.
- Parameters
-
key | The name of the header. |
- Returns
- The value of the header, or null if not found.
◆ IsPendingBody()
bool XmobiTea.ProtonNetCommon.HttpResponse.IsPendingBody |
( |
| ) |
|
Indicates whether the response is pending body processing.
- Returns
- True if the response is pending body processing, otherwise false.
◆ IsPendingHeader()
bool XmobiTea.ProtonNetCommon.HttpResponse.IsPendingHeader |
( |
| ) |
|
Indicates whether the response is pending header processing.
- Returns
- True if the response is pending header processing, otherwise false.
◆ SetBegin()
HttpResponse XmobiTea.ProtonNetCommon.HttpResponse.SetBegin |
( |
StatusCode | status, |
|
|
string | protocol = Constance::DefaultHttpProtocol ) |
Sets the beginning of the response with the specified status and protocol.
- Parameters
-
status | The HTTP status code. |
protocol | The HTTP protocol (default is Constance.DefaultHttpProtocol). |
- Returns
- The current HttpResponse instance.
◆ SetBody() [1/2]
HttpResponse XmobiTea.ProtonNetCommon.HttpResponse.SetBody |
( |
byte[] | body | ) |
|
Sets the body of the response with the specified byte array content.
- Parameters
-
body | The body content as a byte array. |
- Returns
- The current HttpResponse instance.
◆ SetBody() [2/2]
HttpResponse XmobiTea.ProtonNetCommon.HttpResponse.SetBody |
( |
string | body = "" | ) |
|
Sets the body of the response with the specified string content.
- Parameters
-
body | The body content as a string. |
- Returns
- The current HttpResponse instance.
◆ SetBodyBuffer()
bool XmobiTea.ProtonNetCommon.HttpResponse.SetBodyBuffer |
( |
byte[] | buffer, |
|
|
int | position, |
|
|
int | length ) |
Sets the body buffer with the specified byte array data.
- Parameters
-
buffer | The byte array containing body data. |
position | The starting position in the buffer. |
length | The length of the data to write. |
- Returns
- True if the body processing is complete, otherwise false.
◆ SetContentType()
HttpResponse XmobiTea.ProtonNetCommon.HttpResponse.SetContentType |
( |
string | extension | ) |
|
Sets the Content-Type header for the response based on the file extension.
- Parameters
-
extension | The file extension. |
- Returns
- The current HttpResponse instance.
◆ SetCookie()
HttpResponse XmobiTea.ProtonNetCommon.HttpResponse.SetCookie |
( |
string | name, |
|
|
string | value, |
|
|
int | maxAge = 86400, |
|
|
string | path = "", |
|
|
string | domain = "", |
|
|
bool | secure = true, |
|
|
bool | strict = true, |
|
|
bool | httpOnly = true ) |
Sets a cookie with the specified name, value, and optional parameters.
- Parameters
-
name | The name of the cookie. |
value | The value of the cookie. |
maxAge | The maximum age of the cookie in seconds (default is 86400 seconds). |
path | The path where the cookie is valid. |
domain | The domain where the cookie is valid. |
secure | Indicates whether the cookie is secure (default is true). |
strict | Indicates whether the cookie should be SameSite=Strict (default is true). |
httpOnly | Indicates whether the cookie is HttpOnly (default is true). |
- Returns
- The current HttpResponse instance.
◆ SetHeader()
HttpResponse XmobiTea.ProtonNetCommon.HttpResponse.SetHeader |
( |
string | key, |
|
|
string | value ) |
Sets a header with the specified key and value.
- Parameters
-
key | The name of the header. |
value | The value of the header. |
- Returns
- The current HttpResponse instance.
◆ SetHeaderBuffer()
bool XmobiTea.ProtonNetCommon.HttpResponse.SetHeaderBuffer |
( |
byte[] | buffer, |
|
|
int | position, |
|
|
int | length ) |
Sets the header buffer with the specified byte array data.
- Parameters
-
buffer | The byte array containing header data. |
position | The starting position in the buffer. |
length | The length of the data to write. |
- Returns
- True if the header processing is complete, otherwise false.
The documentation for this class was generated from the following file:
- XmobiTea.ProtonNetCommon/HttpResponse.cs