Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V3] Override abstract fields in HttpClientRequestMessage #52

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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