Class WebHttpRequestInterceptor
Definition
- Assembly:
- Tizen.NUI.dll
It is a class for http request interceptor of web view.
public class WebHttpRequestInterceptor : Disposable
- Inheritance
Properties
View SourceHeaders
Gets headers of intercepted http request. Headers is a map with string key-value pairs, for example, "Accept: text/plain", "Accept-Charset: utf-8", etc.
Declaration
public IDictionary<string, string> Headers { get; }
Property Value
Type | Description |
---|---|
IDictionary<, ><string, string> |
InterceptedWebView
Gets webview in which request is intercepted.
Declaration
public WebView InterceptedWebView { get; }
Property Value
Type | Description |
---|---|
WebView |
Method
Gets method of intercepted http request, for example, GET, POST, etc.
Declaration
public string Method { get; }
Property Value
Type | Description |
---|---|
string |
Url
Gets url of intercepted request.
Declaration
public string Url { get; }
Property Value
Type | Description |
---|---|
string |
Methods
View SourceAddResponseHeader(string, string)
Adds HTTP header to response for intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted.
Declaration
public bool AddResponseHeader(string fieldName, string fieldValue)
Parameters
Type | Name | Description |
---|---|---|
string | fieldName | Key of response header |
string | fieldValue | Value of response header |
Returns
Type | Description |
---|---|
bool |
AddResponseHeaders(IDictionary<string, string>)
Adds HTTP headers to response for intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted.
Declaration
public bool AddResponseHeaders(IDictionary<string, string> headers)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<, ><string, string> | headers | Map of response headers |
Returns
Type | Description |
---|---|
bool |
Ignore()
Ignores the http request. When application doesn't have a response for intercepted request, this function would be called which notifies engine to proceed with normal resource loading. It can be called only INSIDE WebContext.HttpRequestIntercepted. After it called, any further call on WebHttpRequestInterceptor results in undefined behavior.
Declaration
public bool Ignore()
Returns
Type | Description |
---|---|
bool |
ReleaseSwigCPtr(HandleRef)
Declaration
protected override void ReleaseSwigCPtr(Runtime.InteropServices.HandleRef swigCPtr)
Parameters
Type | Name | Description |
---|---|---|
Tizen.System.Runtime.InteropServices.HandleRef | swigCPtr |
Overrides
View SourceSetResponse(string, byte[])
Writes whole response body with headers at once. To call it, application should have full response headers and body ready for the intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted. After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
Declaration
public bool SetResponse(string headers, byte[] body)
Parameters
Type | Name | Description |
---|---|---|
string | headers | Headers of response |
byte[] | body | Contents of response |
Returns
Type | Description |
---|---|
bool |
SetResponse(string, string)
Writes whole response body with headers at once. To call it, application should have full response headers and body ready for the intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted. After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
Declaration
public bool SetResponse(string headers, string body)
Parameters
Type | Name | Description |
---|---|---|
string | headers | Headers of response |
string | body | Contents of response. For UTF-8 encoding, body would be got like System.Text.Encoding.UTF8.GetString(...) |
Returns
Type | Description |
---|---|
bool |
SetResponseBody(byte[])
Writes whole response body at once. To call it, application should have full response body ready for the intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted. After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
Declaration
public bool SetResponseBody(byte[] body)
Parameters
Type | Name | Description |
---|---|---|
byte[] | body | Contents of response |
Returns
Type | Description |
---|---|
bool |
SetResponseBody(string)
Writes whole response body at once. To call it, application should have full response body ready for the intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted. After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
Declaration
public bool SetResponseBody(string body)
Parameters
Type | Name | Description |
---|---|---|
string | body | Contents of response. For UTF-8 encoding, body would be got like System.Text.Encoding.UTF8.GetString(...) |
Returns
Type | Description |
---|---|
bool |
SetResponseStatus(int, string)
Sets status code and status text of response for intercepted request. This function can be used inside or outside WebContext.HttpRequestIntercepted.
Declaration
public bool SetResponseStatus(int statusCode, string customStatusText)
Parameters
Type | Name | Description |
---|---|---|
int | statusCode | Status code of response |
string | customStatusText | Status text of response |
Returns
Type | Description |
---|---|
bool |
WriteResponseChunk(byte[])
Writes a part of response body. This function can be called only OUTSIDE WebContext.HttpRequestIntercepted. If it returns false, handling the request is done. Any further calls result in undefined behavior. User should always check return value, because response to this request might not be needed any more, and the function can return false even though user still has data to write.
After writing full response body in chunks using this function, call it again with null as chunk, to signal that response body is finished.
Declaration
public bool WriteResponseChunk(byte[] chunk)
Parameters
Type | Name | Description |
---|---|---|
byte[] | chunk | Chunk of response |
Returns
Type | Description |
---|---|
bool |
WriteResponseChunk(string)
Writes a part of response body. This function can be called only OUTSIDE WebContext.HttpRequestIntercepted. If it returns false, handling the request is done. Any further calls result in undefined behavior. User should always check return value, because response to this request might not be needed any more, and the function can return false even though user still has data to write.
After writing full response body in chunks using this function, call it again with null as chunk, to signal that response body is finished.
Declaration
public bool WriteResponseChunk(string chunk)
Parameters
Type | Name | Description |
---|---|---|
string | chunk | Chunk of response. For UTF-8 encoding, chunk would be got like System.Text.Encoding.UTF8.GetString(...) |
Returns
Type | Description |
---|---|
bool |