CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
HttpCompressionProxy.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="HttpCompressionProxy.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Implements a data portal proxy to relay data portal</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Net;
10using System.Net.Http;
11
13{
19 {
24 protected override HttpClientHandler GetHttpClientHandler()
25 {
26 var result = new HttpClientHandler();
28 result.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
29 return result;
30 }
31
37 protected override void SetHttpRequestHeaders(HttpRequestMessage request)
38 {
39 request.Headers.Add("Accept", "*/*");
40 request.Headers.Add("Accept-Encoding", "gzip,deflate,*");
41 }
42
47 protected override WebClient GetWebClient()
48 {
49 var client = new CompressionWebClient(Timeout);
50 client.Headers.Set("Accept", "*/*");
51 client.Headers.Set("Accept-Encoding", "gzip,deflate,*");
52 return client;
53 }
54
55 private class CompressionWebClient : WebClient
56 {
57 private int Timeout { get; set; }
58
59 public CompressionWebClient(int timeout)
60 {
61 Timeout = timeout;
62 }
63
64 protected override WebRequest GetWebRequest(Uri address)
65 {
66 var req = base.GetWebRequest(address) as HttpWebRequest;
67 req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
68 if (Timeout > 0)
69 req.Timeout = Timeout;
70 return req;
71 }
72 }
73 }
74}
virtual int Timeout
Gets or sets the Client timeout in milliseconds (0 uses default timeout).
Implements a data portal proxy to relay data portal calls to a remote application server by using htt...
override HttpClientHandler GetHttpClientHandler()
Gets an HttpClientHandler for use in initializing the HttpClient instance.
override void SetHttpRequestHeaders(HttpRequestMessage request)
Override to set headers or other properties of the HttpRequestMessage before it is sent to the server...
override WebClient GetWebClient()
Gets an WebClient object for use in communication with the server.
Implements a data portal proxy to relay data portal calls to a remote application server by using htt...
Definition: HttpProxy.cs:27
static bool UseTextSerialization
Gets or sets a value indicating whether to use text/string serialization instead of the default binar...
Definition: HttpProxy.cs:124