added NewGetRequest helper

This commit is contained in:
Andrew Gerrand 2011-01-15 12:25:24 +11:00
parent 8933895fd1
commit ee937f8d7f
1 changed files with 13 additions and 0 deletions

View File

@ -170,6 +170,19 @@ func (cr *ClientRequest) Send() (r *Response, err os.Error) {
return send(cr.Request) return send(cr.Request)
} }
func NewGetRequest(url string) (*ClientRequest) {
req := new(ClientRequest)
req.Request = new(Request)
req.Method = "GET"
req.ProtoMajor = 1
req.ProtoMinor = 1
req.Close = true
req.Header = make(map[string]string)
req.TransferEncoding = []string{"chunked"}
req.URL, req.error = ParseURL(url)
return req
}
func NewPostRequest(url string, bodyType string, body io.Reader) (*ClientRequest) { func NewPostRequest(url string, bodyType string, body io.Reader) (*ClientRequest) {
req := new(ClientRequest) req := new(ClientRequest)
req.Request = new(Request) req.Request = new(Request)