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

HttpResponseMessage Response in RequestResult marked as Obsolete #1059

Closed
Pedro-Monteiro-1211076 opened this issue Apr 29, 2024 · 5 comments · Fixed by #1063
Closed

HttpResponseMessage Response in RequestResult marked as Obsolete #1059

Pedro-Monteiro-1211076 opened this issue Apr 29, 2024 · 5 comments · Fixed by #1063

Comments

@Pedro-Monteiro-1211076
Copy link

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.

@nozzlegear
Copy link
Owner

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.

@Pedro-Monteiro-1211076
Copy link
Author

Pedro-Monteiro-1211076 commented May 10, 2024

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.

@nozzlegear
Copy link
Owner

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.

nozzlegear added a commit that referenced this issue May 14, 2024
nozzlegear added a commit that referenced this issue May 14, 2024
@nozzlegear
Copy link
Owner

@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!

@Pedro-Monteiro-1211076
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants