Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(186)

Side by Side Diff: src/pkg/http/fs.go

Issue 4661051: code review 4661051: strings.Split: make the default to split all. (Closed)
Patch Set: diff -r eaa696629d4d https://go.googlecode.com/hg/ Created 12 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/http/cookie.go ('k') | src/pkg/http/request.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // HTTP file system request handler 5 // HTTP file system request handler
6 6
7 package http 7 package http
8 8
9 import ( 9 import (
10 "fmt" 10 "fmt"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // parseRange parses a Range header string as per RFC 2616. 252 // parseRange parses a Range header string as per RFC 2616.
253 func parseRange(s string, size int64) ([]httpRange, os.Error) { 253 func parseRange(s string, size int64) ([]httpRange, os.Error) {
254 if s == "" { 254 if s == "" {
255 return nil, nil // header not present 255 return nil, nil // header not present
256 } 256 }
257 const b = "bytes=" 257 const b = "bytes="
258 if !strings.HasPrefix(s, b) { 258 if !strings.HasPrefix(s, b) {
259 return nil, os.NewError("invalid range") 259 return nil, os.NewError("invalid range")
260 } 260 }
261 var ranges []httpRange 261 var ranges []httpRange
262 » for _, ra := range strings.Split(s[len(b):], ",", -1) { 262 » for _, ra := range strings.Split(s[len(b):], ",") {
263 i := strings.Index(ra, "-") 263 i := strings.Index(ra, "-")
264 if i < 0 { 264 if i < 0 {
265 return nil, os.NewError("invalid range") 265 return nil, os.NewError("invalid range")
266 } 266 }
267 start, end := ra[:i], ra[i+1:] 267 start, end := ra[:i], ra[i+1:]
268 var r httpRange 268 var r httpRange
269 if start == "" { 269 if start == "" {
270 // If no start is specified, end specifies the 270 // If no start is specified, end specifies the
271 // range start relative to the end of the file. 271 // range start relative to the end of the file.
272 i, err := strconv.Atoi64(end) 272 i, err := strconv.Atoi64(end)
(...skipping 22 matching lines...) Expand all
295 if i >= size { 295 if i >= size {
296 i = size - 1 296 i = size - 1
297 } 297 }
298 r.length = i - r.start + 1 298 r.length = i - r.start + 1
299 } 299 }
300 } 300 }
301 ranges = append(ranges, r) 301 ranges = append(ranges, r)
302 } 302 }
303 return ranges, nil 303 return ranges, nil
304 } 304 }
OLDNEW
« no previous file with comments | « src/pkg/http/cookie.go ('k') | src/pkg/http/request.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b