From e5232e745b2d431135f684e561d588a384d39290 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 30 Dec 2011 17:13:42 -0500 Subject: [PATCH] Use http.NewRequest --- src/server.go | 11 ++++++----- src/tv_rename.go | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/server.go b/src/server.go index 5715610..508da5a 100644 --- a/src/server.go +++ b/src/server.go @@ -138,16 +138,17 @@ func performProxy(url_ *url.URL, response http.ResponseWriter, origRequest *http return err } client := http.NewClientConn(conn, nil) - var request http.Request - request.URL = url_ - request.Method = "GET" + request, err := http.NewRequest("GET", url_.String(), nil) + if err != nil { + return err + } request.Header.Set("User-Agent", origRequest.UserAgent()) - err = client.Write(&request) + err = client.Write(request) if err != nil { return err } var proxyResponse *http.Response - proxyResponse, err = client.Read(&request) + proxyResponse, err = client.Read(request) if err != nil && err != http.ErrPersistEOF { return err } diff --git a/src/tv_rename.go b/src/tv_rename.go index 9d0eeab..62cfd93 100644 --- a/src/tv_rename.go +++ b/src/tv_rename.go @@ -127,15 +127,16 @@ func performLookup(urlString string) (*http.Response, os.Error) { // Perform the HTTP request. client := http.NewClientConn(conn, nil) - var request http.Request - request.URL = url_ - request.Method = "GET" + request, err := http.NewRequest("GET", urlString, nil) + if err != nil { + return nil, err + } request.Header.Set("User-Agent", "Armadillo File Manager") - err = client.Write(&request) + err = client.Write(request) if err != nil { return nil, err } - return client.Read(&request) + return client.Read(request) } // Parses the HTTP response from performLookup(). -- 2.43.5