-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to detect server response status code #52
Comments
For sure demo code :
|
I don't know how i missed it. Thank you |
The response is not available when there is an error (not success status code) on the TusHeadAsync, TusOptionAsync and TusDeleteAsync |
I suggest that you get that exception with try catch code, and then you can know why there is an error. |
The exception has very limited information about what happened and this information is included in Message string. Parsing message is not a good way to detect for example status code. |
Netstandard 2.0 does not have such property. And still it is very limited if available. IMO the response should be accessible in some way. |
Can you show me an exception, I may resolve your problem |
"InnerException": { at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() |
Which method did throw an exception? |
|
It is so weird, I think HeadMethod never gets an 409 exception, You can refer to https://tus.io/protocols/resumable-upload#concatenation |
The 409 status is only an example of response which is not possible to handle. Other statuses are also not possible to verify. According to the 409 Conflict it is known issue with Kestrel selfhost and tusdotnet implementation: |
OK, I understand. If you do not know how to handle an exceptional status, I can handle it for you. If you want to log which exceptional status with codes, I suggest you run your code on net core runtime. By the way, I want to know why do want to detect the server response status code, Because I think logging exceptional Messages is enough |
The status code is required to act accordingly when it is 409 or 404 or 401 or other status (maybe 5**). And whether to retry sending file or stop retrying if error is permanent. |
Okay, I see. I will think about that. |
I suggest retrying invoking method as long as there is an exception and you set Max retry times |
Some exceptions (status codes) are permanent and it is pointless to repeat the request. |
Yep, I totally agree. You can avoid that by setting Max retry times at present.
You are welcome, I will handle your problem by throwing a custom exception which contains any information you want |
I have been released v3.1.2 |
I would like to detect when server responses with 409 or 404 or other status code and act accordingly. Is it possible to do it with your library? As I can see your library throws HttpRequestException but it does not allow to get status code.
The text was updated successfully, but these errors were encountered: