Skip to content

Commit

Permalink
Added a few more properties to the "SocialHttpRequest" class
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Jul 7, 2018
1 parent 5cef4a0 commit 4400adc
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/Skybrud.Social.Core/Http/SocialHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class SocialHttpRequest {
/// <summary>
/// Gets or sets the credentials (username and password) of the request.
/// </summary>
public NetworkCredential Credentials { get; set; }
public ICredentials Credentials { get; set; }

/// <summary>
/// Gets or sets the URL of the request. The query string can either be specified directly in the URL, or
Expand Down Expand Up @@ -171,6 +171,35 @@ public string Authorization {

#endregion

#if NET_STANDARD2

/// <summary>
/// Gets or sets the type of decompression that is used.
/// </summary>
public DecompressionMethods AutomaticDecompression { get; set; }

/// <summary>
/// Gets or sets the media type of the request.
/// </summary>
public string MediaType { get; set; }

/// <summary>
/// Gets or sets the value of the <strong>Transfer-encoding</strong> HTTP header.
/// </summary>
public string TransferEncoding { get; set; }

/// <summary>
/// Gets or sets the value of the <strong>Connection</strong> HTTP header.
/// </summary>
public string Connection { get; set; }

/// <summary>
/// Gets or sets the value of the <strong>Expect</strong> HTTP header.
/// </summary>
public string Expect { get; set; }

#endif

#endregion

#region Constructor
Expand Down Expand Up @@ -221,17 +250,29 @@ public SocialHttpResponse GetResponse(Action<HttpWebRequest> callback) {
request.CookieContainer = Cookies;
if (!String.IsNullOrWhiteSpace(ContentType)) request.ContentType = ContentType;

request.AllowReadStreamBuffering = true;

#if NET_FRAMEWORK
request.Timeout = (int) Timeout.TotalMilliseconds;
if (!String.IsNullOrWhiteSpace(Host)) request.Host = Host;
if (!String.IsNullOrWhiteSpace(UserAgent)) request.UserAgent = UserAgent;
if (!String.IsNullOrWhiteSpace(Referer)) request.Referer = Referer;
#endif

#if NET_STANDARD2
request.AutomaticDecompression = AutomaticDecompression;
request.MediaType = MediaType;
request.TransferEncoding = TransferEncoding;
request.Connection = Connection;
request.Expect = Expect;
#endif

#if NET_STANDARD
if (!String.IsNullOrWhiteSpace(Host)) request.Headers["Host"] = Host;
if (!String.IsNullOrWhiteSpace(UserAgent)) request.Headers["User-Agent"] = UserAgent;
if (!String.IsNullOrWhiteSpace(Referer)) request.Headers["Referer"] = Referer;


#endif

// Handle various POST scenarios
Expand Down

0 comments on commit 4400adc

Please sign in to comment.