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

Side by Side Diff: src/pkg/net/http/request_test.go

Issue 7532043: code review 7532043: net/http: change user agent string (Closed)
Patch Set: diff -r 3beef801220b https://code.google.com/p/go/ Created 11 years 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/net/http/request.go ('k') | src/pkg/net/http/requestwrite_test.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 package http_test 5 package http_test
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "bytes" 9 "bytes"
10 "fmt" 10 "fmt"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return len(p), nil 282 return len(p), nil
283 } 283 }
284 284
285 func TestRequestWriteBufferedWriter(t *testing.T) { 285 func TestRequestWriteBufferedWriter(t *testing.T) {
286 got := []string{} 286 got := []string{}
287 req, _ := NewRequest("GET", "http://foo.com/", nil) 287 req, _ := NewRequest("GET", "http://foo.com/", nil)
288 req.Write(logWrites{t, &got}) 288 req.Write(logWrites{t, &got})
289 want := []string{ 289 want := []string{
290 "GET / HTTP/1.1\r\n", 290 "GET / HTTP/1.1\r\n",
291 "Host: foo.com\r\n", 291 "Host: foo.com\r\n",
292 » » "User-Agent: Go http package\r\n", 292 » » "User-Agent: " + DefaultUserAgent + "\r\n",
293 "\r\n", 293 "\r\n",
294 } 294 }
295 if !reflect.DeepEqual(got, want) { 295 if !reflect.DeepEqual(got, want) {
296 t.Errorf("Writes = %q\n Want = %q", got, want) 296 t.Errorf("Writes = %q\n Want = %q", got, want)
297 } 297 }
298 } 298 }
299 299
300 func testMissingFile(t *testing.T, req *Request) { 300 func testMissingFile(t *testing.T, req *Request) {
301 f, fh, err := req.FormFile("missing") 301 f, fh, err := req.FormFile("missing")
302 if f != nil { 302 if f != nil {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 Connection: keep-alive 472 Connection: keep-alive
473 `) 473 `)
474 } 474 }
475 475
476 func BenchmarkReadRequestWrk(b *testing.B) { 476 func BenchmarkReadRequestWrk(b *testing.B) {
477 // wrk -t 1 -r 1 -c 1 http://localhost:8080/ 477 // wrk -t 1 -r 1 -c 1 http://localhost:8080/
478 benchmarkReadRequest(b, `GET / HTTP/1.1 478 benchmarkReadRequest(b, `GET / HTTP/1.1
479 Host: localhost:8080 479 Host: localhost:8080
480 `) 480 `)
481 } 481 }
OLDNEW
« no previous file with comments | « src/pkg/net/http/request.go ('k') | src/pkg/net/http/requestwrite_test.go » ('j') | no next file with comments »

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