RestResponse.Request not populated on 102.3

59 views
Skip to first unread message

Damian

unread,
Nov 4, 2011, 12:38:28 AM11/4/11
to RestSharp
Hi,
i found that RestResponse.Request is not populated, so the
RestRequest.UserState cannot be used.

I have added it in RestClientAsync.cs, to ProcessResponse() and
ConvertToRestResponse() methods

private void ProcessResponse(HttpResponse httpResponse, IRestRequest
request, RestRequestAsyncHandle asyncHandle, Action<RestResponse,
RestRequestAsyncHandle> callback)
{
var restResponse = ConvertToRestResponse(request, httpResponse);
callback(restResponse, asyncHandle);
}




I had to also add it copy operator in RestResponse.cs so it will be
returned in the generic RestResponse<>

public static explicit operator RestResponse<T>(RestResponse
response)
{
return new RestResponse<T>
{
ContentEncoding = response.ContentEncoding,
ContentLength = response.ContentLength,
ContentType = response.ContentType,
Cookies = response.Cookies,
ErrorMessage = response.ErrorMessage,
Headers = response.Headers,
RawBytes = response.RawBytes,
ResponseStatus = response.ResponseStatus,
ResponseUri = response.ResponseUri,
Server = response.Server,
StatusCode = response.StatusCode,
StatusDescription = response.StatusDescription,
Request = response.Request
};
}



regards,
Damian

Andrew Young

unread,
Nov 4, 2011, 12:47:24 AM11/4/11
to rest...@googlegroups.com
Can you send a pull request on GitHub?

Damian

unread,
Nov 4, 2011, 2:00:25 AM11/4/11
to RestSharp
i'll have to work out how to use github..

also IRestRequest is missing
object UserState { get; set; }

As IRestRequest gets used internally, the UserState gets lost when it
comes back on RestResponse.Request
> > Damian- Hide quoted text -
>
> - Show quoted text -

John Sheehan

unread,
Nov 15, 2011, 5:27:22 PM11/15/11
to rest...@googlegroups.com
this is a bug and can be added as an issue on github http://github.com/restsharp/RestSharp/issues
Reply all
Reply to author
Forward
0 new messages