Skip to content

Commit

Permalink
[V3] Override abstract fields in HttpClientRequestMessage (#52)
Browse files Browse the repository at this point in the history
* Override abstract fields in HttpClientRequestMessage

* same if
  • Loading branch information
fannydengdeng committed Oct 4, 2021
1 parent 2347aa6 commit 1697f89
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,39 @@ public override ICredentials Credentials
}
}

#if !ASTORIA_LIGHT && !PORTABLELIB
/// <summary>
/// Gets or sets the timeout (in seconds) for this request.
/// </summary>
public override int Timeout
{
get
{
return (int)this.client.Timeout.TotalSeconds;
}
set
{
this.client.Timeout = new TimeSpan(0, 0, value);
}
}

/// <summary>
/// Gets or sets a value that indicates whether to send data in segments to the Internet resource.
/// </summary>
public override bool SendChunked
{
get
{
bool? transferEncodingChunked = this.requestMessage.Headers.TransferEncodingChunked;
return transferEncodingChunked.HasValue && transferEncodingChunked.Value;
}
set
{
this.requestMessage.Headers.TransferEncodingChunked = value;
}
}
#endif

/// <summary>
/// Returns the value of the header with the given name.
/// </summary>
Expand Down Expand Up @@ -255,6 +288,22 @@ public override IODataResponseMessage EndGetResponse(IAsyncResult asyncResult)
return UnwrapAggregateException(() => new HttpClientResponseMessage(((Task<HttpResponseMessage>)asyncResult).Result, this.config));
}

#if !ASTORIA_LIGHT && !PORTABLELIB
/// <summary>
/// Returns a response from an Internet resource.
/// </summary>
/// <returns>A System.Net.WebResponse that contains the response from the Internet resource.</returns>
public override IODataResponseMessage GetResponse()
{
return UnwrapAggregateException(() =>
{
var send = CreateSendTask();
send.Wait();
return new HttpClientResponseMessage(send.Result, this.config);
});
}
#endif

private Task<HttpResponseMessage> CreateSendTask()
{
// Only set the message content if the stream has been written to, otherwise
Expand Down

0 comments on commit 1697f89

Please sign in to comment.