ShopifySharp
ShopifySharp copied to clipboard
HttpResponseMessage Response in RequestResult marked as Obsolete
I am logging HTTP requests and responses by creating an IRequestExecutionPolicy. Below is a simplified version of my class without the logging:
public class LoggingExecutionPolicy<T> : IRequestExecutionPolicy
{
public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage requestMessage, ExecuteRequestAsync<T> executeRequestAsync,
CancellationToken cancellationToken, int? graphqlQueryCost = null)
{
// Send request
var result = await executeRequestAsync(requestMessage);
return result;
}
}
I have no problem logging the request. To log the response I use the result variable which is of the type RequestResult. This class has the attribute HttpResponseMessage Response which is perfect to log the response (I just need the status code). However, it is marked as Obsolete and I am wondering what should I use instead to obtain the status code.
Hey @Pedro-Monteiro-1211076, sorry it took so long to respond, I meant to get back to you right away. Thanks for pointing this out! I can see how it'd be useful to have the status code here, I'll make sure it gets added to the RequestResult class in my next release.
Hello @nozzlegear, no worries. Thanks for considering my suggestion and implementing it! Do you have an estimate of when you will publish the next release? Keep up the good work.
Planning to release it today (Monday)! I've got a new request execution policy I'm cooking up that I'd like to release as well, just need to finish up the tests for that and then I'll push out a release for both of them.
@Pedro-Monteiro-1211076 A couple days late, but this is now published in 6.16.0 on Nuget. You should be able to access the status code with result.HttpStatusCode once you update to the latest version. Let me know if you have any trouble using it!
Hey @nozzlegear, I have updated the Nuget and everything seems to be working fine. Thank you very much. I have just realized that the content of the response (which is obselete) would also be useful, do you think that in a future release that could be added?