2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
24 /// It is a class for http request interceptor of web view.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class WebHttpRequestInterceptor : Disposable
29 internal WebHttpRequestInterceptor(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
33 /// This will not be public opened.
34 /// <param name="swigCPtr"></param>
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
38 Interop.WebHttpRequestInterceptor.DeleteWebHttpRequestInterceptor(swigCPtr);
42 /// Gets url of intercepted request.
44 [EditorBrowsable(EditorBrowsableState.Never)]
49 return Interop.WebHttpRequestInterceptor.GetUrl(SwigCPtr);
54 /// Ignores this request.
56 [EditorBrowsable(EditorBrowsableState.Never)]
59 bool result = Interop.WebHttpRequestInterceptor.Ignore(SwigCPtr);
60 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65 /// Sets status code and status text of response for intercepted request.
66 /// <param name="statusCode">Status code of response</param>
67 /// <param name="customStatusText">Status text of response</param>
69 [EditorBrowsable(EditorBrowsableState.Never)]
70 public bool SetResponseStatus(int statusCode, string customStatusText)
72 bool result = Interop.WebHttpRequestInterceptor.SetResponseStatus(SwigCPtr, statusCode, customStatusText);
73 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78 /// Adds HTTP header to response for intercepted request.
79 /// <param name="fieldName">Key of response header</param>
80 /// <param name="fieldValue">Value of response header</param>
82 [EditorBrowsable(EditorBrowsableState.Never)]
83 public bool AddResponseHeader(string fieldName, string fieldValue)
85 bool result = Interop.WebHttpRequestInterceptor.AddResponseHeader(SwigCPtr, fieldName, fieldValue);
86 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91 /// Writes whole response body at once.
92 /// <param name="body">Contents of response</param>
93 /// <param name="length">Length of Contents of response</param>
95 [EditorBrowsable(EditorBrowsableState.Never)]
96 public bool AddResponseBody(string body, uint length)
98 bool result = Interop.WebHttpRequestInterceptor.AddResponseBody(SwigCPtr, body, length);
99 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();