Skip to content

Commit

Permalink
fix(scraper): improve content type check
Browse files Browse the repository at this point in the history
  • Loading branch information
ncarlier committed Jun 10, 2020
1 parent d248eca commit f8259b8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/scraper/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
"time"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -63,7 +64,7 @@ func (ws extrenalWebScraper) scrap(ctx context.Context, url string) (*WebPage, e
}

if ct := res.Header.Get("Content-Type"); ct != "" {
if ct != "application/json" {
if !strings.HasPrefix(ct, "application/json") {
return nil, fmt.Errorf("invalid web scraping Content-Type response: %s", ct)
}
}
Expand Down

0 comments on commit f8259b8

Please sign in to comment.