jgiacomini / Tiny.RestClient

Simpliest Fluent REST client for .NET
MIT License
210 stars 30 forks source link

Add possibility to accept non 200 http status code in response #81

Closed jgiacomini closed 4 years ago

jgiacomini commented 5 years ago

Add the possibility to accept non http2xx status codes.

80

guillaumechervetaxa commented 5 years ago

Great new :) Thank you very much! Do you have some Unit Test associated? Because I 'am not inside your project, I will understand more your code with some tests.

jgiacomini commented 5 years ago

I have updated the readme => you can see how to use it.

After you validate it I will write somes tests :)

jgiacomini commented 5 years ago

@guillaumechervetaxa if you are ok with the API (below) I can implement it like that. :)

A sample how to use it globaly :

Allow non http 2xx responses (for all requests)

Allow all status code :

client.Settings.HttpStatusCodeAllowed.AllowAllStatus = true;

Allow only a range of http status codes :

client.Settings.HttpStatusCodeAllowed.Add(new HttpStatusRange(400, 420));

Allow only on stats code of http status codes :

client.Settings.HttpStatusCodeAllowed.Add(new HttpStatusRange(409));

Allow non http 2xx responses (by request)

Allow all status code :

request.AllowAllHttpStatusCode().ExecuteAsync();

Allow only a range of http status codes :

request.AllowRangeHttpStatusCode(400, 420).ExecuteAsync();

Allow only on stats code of http status codes :

request.AllowSpecificHttpStatusCode(409).ExecuteAsync();
Lordinaire commented 5 years ago

By default, I prefer to set AllowAllStatus to true.

jgiacomini commented 5 years ago

By default, I prefer to set AllowAllStatus to true.

It's a good point haha.

I will change that

jgiacomini commented 5 years ago

I have to implements methods + tests and after I merge it :)

jgiacomini commented 4 years ago

After 9 months of inactivity (sorry for that) the PR is ready. Anyone to review it?