diff --git a/colly.go b/colly.go index ae74b7c3..83fc3403 100644 --- a/colly.go +++ b/colly.go @@ -539,7 +539,7 @@ func (c *Collector) Head(URL string) error { // Post starts a collector job by creating a POST request. // Post also calls the previously provided callbacks func (c *Collector) Post(URL string, requestData map[string]string) error { - return c.scrape(URL, "POST", 1, createFormReader(requestData), nil, nil, true) + return c.scrape(URL, "POST", 1, CreateFormReader(requestData), nil, nil, true) } // PostRaw starts a collector job by creating a POST request with raw binary data. @@ -1425,7 +1425,7 @@ func (c *Collector) parseSettingsFromEnv() { } func (c *Collector) checkHasVisited(URL string, requestData map[string]string) (bool, error) { - hash := requestHash(URL, createFormReader(requestData)) + hash := requestHash(URL, CreateFormReader(requestData)) return c.store.IsVisited(hash) } @@ -1444,7 +1444,8 @@ func SanitizeFileName(fileName string) string { ), "-", "_", -1) } -func createFormReader(data map[string]string) io.Reader { +// CreateFormReader creates a form reader from a map. +func CreateFormReader(data map[string]string) io.Reader { form := url.Values{} for k, v := range data { form.Add(k, v) diff --git a/request.go b/request.go index 5c80e2bb..fe4d71e3 100644 --- a/request.go +++ b/request.go @@ -128,7 +128,7 @@ func (r *Request) HasVisited(URL string) (bool, error) { // of the previous request. // Post also calls the previously provided callbacks func (r *Request) Post(URL string, requestData map[string]string) error { - return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, createFormReader(requestData), r.Ctx, nil, true) + return r.collector.scrape(r.AbsoluteURL(URL), "POST", r.Depth+1, CreateFormReader(requestData), r.Ctx, nil, true) } // PostRaw starts a collector job by creating a POST request with raw binary data.