1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-01-16 03:21:03 +02:00

added back allowedHTTPCodes function

This commit is contained in:
gabriel-m 2019-10-16 00:54:42 +02:00 committed by GitHub
parent d0a3218b9a
commit cdc6573d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,7 +152,7 @@ func (drv *Driver) Open(ctx context.Context, params drivers.Params) (drivers.HTM
defer resp.Body.Close()
if _, exists := drv.options.AllowedHTTPCodes[resp.StatusCode]; !exists {
if !drv.responseCodeAllowed(resp) {
return nil, errors.New(resp.Status)
}
@ -177,6 +177,11 @@ func (drv *Driver) Open(ctx context.Context, params drivers.Params) (drivers.HTM
return NewHTMLPage(doc, params.URL, &r, cookies)
}
func (drv *Driver) responseCodeAllowed(resp *http.Response) bool {
_, exists := drv.options.AllowedHTTPCodes[resp.StatusCode]
return exists
}
func (drv *Driver) Parse(_ context.Context, str values.String) (drivers.HTMLPage, error) {
buf := bytes.NewBuffer([]byte(str))