protected virtual UnityWebRequest OnCreateWebRequest(IWebRequest request) { string method = WebRequestUtility.GetMethodName(request.Method); var unityWebRequest = new UnityWebRequest(request.Url, method) { redirectLimit = Description.RedirectLimit, timeout = Description.Timeout, useHttpContinue = Description.UseHttpContinue }; foreach ((string key, string value) in request.Headers) { unityWebRequest.SetRequestHeader(key, value); } OnCreateUploadHandler(request, unityWebRequest); OnCreateDownloadHandler(request, unityWebRequest); return(unityWebRequest); }
protected virtual HttpRequestMessage OnCreateRequestMessage(IWebRequest request) { string methodName = WebRequestUtility.GetMethodName(request.Method); var method = new HttpMethod(methodName); var message = new HttpRequestMessage(method, request.Url); foreach ((string key, string value) in request.Headers) { message.Headers.TryAddWithoutValidation(key, value); } if (request.TryGetData(out byte[] bytes)) { message.Content = new ByteArrayContent(bytes); foreach ((string key, string value) in request.Headers) { message.Content.Headers.TryAddWithoutValidation(key, value); } } return(message); }