From 15d49f72875c4a567ac8c33df8998c52ffcfbc99 Mon Sep 17 00:00:00 2001 From: "Axel.Belinfante@cs.utwente.nl" Date: Fri, 11 Mar 2011 17:38:17 +0100 Subject: [PATCH] fixes for release.2011-03-07.1 --- httplib.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/httplib.go b/httplib.go index bffe9f4..97b2861 100644 --- a/httplib.go +++ b/httplib.go @@ -86,7 +86,7 @@ func getResponse(rawUrl string, req *http.Request) (*http.ClientConn, *http.Resp return conn, resp, nil } -func (client *Client) Request(rawurl string, method string, headers map[string]string, body string) (*http.Response, os.Error) { +func (client *Client) Request(rawurl string, method string, headers http.Header, body string) (*http.Response, os.Error) { var url *http.URL var err os.Error if url, err = http.ParseURL(rawurl); err != nil { @@ -98,7 +98,7 @@ func (client *Client) Request(rawurl string, method string, headers map[string]s } if headers == nil { - headers = map[string]string{} + headers = make(http.Header) } client.lastURL = url @@ -106,7 +106,7 @@ func (client *Client) Request(rawurl string, method string, headers map[string]s req.URL = url req.Method = method req.Header = headers - req.UserAgent = headers["User-Agent"] + req.UserAgent = headers.Get("User-Agent") if req.UserAgent == "" { req.UserAgent = "httplib.go" } @@ -128,7 +128,7 @@ func (client *Client) Request(rawurl string, method string, headers map[string]s func Get(url string) *HttpRequestBuilder { var req http.Request req.Method = "GET" - req.Header = map[string]string{} + req.Header = make(http.Header) req.UserAgent = defaultUserAgent return &HttpRequestBuilder{url, &req, nil, map[string]string{}} } @@ -136,7 +136,7 @@ func Get(url string) *HttpRequestBuilder { func Post(url string) *HttpRequestBuilder { var req http.Request req.Method = "POST" - req.Header = map[string]string{} + req.Header = make(http.Header) req.UserAgent = defaultUserAgent return &HttpRequestBuilder{url, &req, nil, map[string]string{}} } @@ -144,7 +144,7 @@ func Post(url string) *HttpRequestBuilder { func Put(url string) *HttpRequestBuilder { var req http.Request req.Method = "PUT" - req.Header = map[string]string{} + req.Header = make(http.Header) req.UserAgent = defaultUserAgent return &HttpRequestBuilder{url, &req, nil, map[string]string{}} } @@ -152,7 +152,7 @@ func Put(url string) *HttpRequestBuilder { func Delete(url string) *HttpRequestBuilder { var req http.Request req.Method = "DELETE" - req.Header = map[string]string{} + req.Header = make(http.Header) req.UserAgent = defaultUserAgent return &HttpRequestBuilder{url, &req, nil, map[string]string{}} } @@ -195,7 +195,7 @@ func (b *HttpRequestBuilder) getResponse() (*http.Response, os.Error) { } func (b *HttpRequestBuilder) Header(key, value string) *HttpRequestBuilder { - b.req.Header[key] = value + b.req.Header.Set(key, value) // choice: use Set or Add? or expose the difference? return b }