partial fetching of artist
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/publicsuffix"
|
||||
@@ -118,6 +119,33 @@ func (s *Session) PostMultipartForm(url string, data map[string]string, headers
|
||||
return s.client.Do(req)
|
||||
}
|
||||
|
||||
func (s *Session) PostForm(rawUrl string, data map[string]string, headers ...map[string]string) (*http.Response, error) {
|
||||
fullURL := s.buildURL(rawUrl)
|
||||
|
||||
// Prepare form data
|
||||
formData := url.Values{}
|
||||
for k, v := range data {
|
||||
formData.Add(k, v)
|
||||
}
|
||||
body := strings.NewReader(formData.Encode())
|
||||
req, err := http.NewRequest("POST", fullURL, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.setDefaultHeaders(req)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
// Add any additional headers provided
|
||||
if len(headers) > 0 {
|
||||
for key, value := range headers[0] {
|
||||
req.Header.Set(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
return s.client.Do(req)
|
||||
}
|
||||
|
||||
// PostJSON performs a POST request with JSON data
|
||||
func (s *Session) PostJSON(url string, data interface{}, headers ...map[string]string) (*http.Response, error) {
|
||||
fullURL := s.buildURL(url)
|
||||
|
||||
Reference in New Issue
Block a user