Closed Spedge closed 6 years ago
Thanks for the suggestion. To keep things simple, I've added a 2XX check in 15e1314, rather than setting a whitelist. The problem with a whitelist is I should probably set a default list. I could use the HTTP spec to build the list, but many servers stray from the spec and could cause undesirable client behaviour.
I'll also look at adding a callback hook, so you can provide custom validation behaviours before the download starts.
If you'd like more granular validation of response codes, please use Request.BeforeCopy
hook: https://godoc.org/github.com/cavaliercoder/grab#Hook. Introduced in 7f4e1fc.
Loving the library but been forced to use something else recently, due to the fact that if a 404 Status Code has a body, grab will still download and save it.
In this case, it wasn't the file I wanted but a JSON payload telling me it didn't exist.
If I could whitelist the status codes I wanted to accept, that'd be great (maybe I've missed how to do this)
Thanks!