summaryrefslogtreecommitdiff
path: root/src/pkg/http/request.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-07-08 09:16:22 +0200
committerOndřej Surý <ondrej@sury.org>2011-07-08 09:16:22 +0200
commitab23f6dab91e6ec615481c4b3e77e4639c3f871b (patch)
treef897fd3be56fdc3599a88df375c76bc172108fd1 /src/pkg/http/request.go
parent8d00b02d82d86abe51773dc2c1751843bb538ae5 (diff)
downloadgolang-ab23f6dab91e6ec615481c4b3e77e4639c3f871b.tar.gz
Imported Upstream version 2011.07.07upstream-weekly/2011.07.07
Diffstat (limited to 'src/pkg/http/request.go')
-rw-r--r--src/pkg/http/request.go19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/pkg/http/request.go b/src/pkg/http/request.go
index 183a35c71..2917cc1e6 100644
--- a/src/pkg/http/request.go
+++ b/src/pkg/http/request.go
@@ -428,10 +428,6 @@ type chunkedReader struct {
err os.Error
}
-func newChunkedReader(r *bufio.Reader) *chunkedReader {
- return &chunkedReader{r: r}
-}
-
func (cr *chunkedReader) beginChunk() {
// chunk-size CRLF
var line string
@@ -511,13 +507,6 @@ func NewRequest(method, url string, body io.Reader) (*Request, os.Error) {
req.ContentLength = int64(v.Len())
case *bytes.Buffer:
req.ContentLength = int64(v.Len())
- default:
- req.ContentLength = -1 // chunked
- }
- if req.ContentLength == 0 {
- // To prevent chunking and disambiguate this
- // from the default ContentLength zero value.
- req.TransferEncoding = []string{"identity"}
}
}
@@ -550,7 +539,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) {
}
var f []string
- if f = strings.Split(s, " ", 3); len(f) < 3 {
+ if f = strings.SplitN(s, " ", 3); len(f) < 3 {
return nil, &badStringError{"malformed HTTP request", s}
}
req.Method, req.RawURL, req.Proto = f[0], f[1], f[2]
@@ -669,11 +658,11 @@ func ParseQuery(query string) (m Values, err os.Error) {
}
func parseQuery(m Values, query string) (err os.Error) {
- for _, kv := range strings.Split(query, "&", -1) {
+ for _, kv := range strings.Split(query, "&") {
if len(kv) == 0 {
continue
}
- kvPair := strings.Split(kv, "=", 2)
+ kvPair := strings.SplitN(kv, "=", 2)
var key, value string
var e os.Error
@@ -710,7 +699,7 @@ func (r *Request) ParseForm() (err os.Error) {
return os.NewError("missing form body")
}
ct := r.Header.Get("Content-Type")
- switch strings.Split(ct, ";", 2)[0] {
+ switch strings.SplitN(ct, ";", 2)[0] {
case "text/plain", "application/x-www-form-urlencoded", "":
const maxFormSize = int64(10 << 20) // 10 MB is a lot of text.
b, e := ioutil.ReadAll(io.LimitReader(r.Body, maxFormSize+1))