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

Delta Between Two Patch Sets: src/pkg/net/http/request_test.go

Issue 76540043: code review 76540043: net/http: add BasicAuth method to *http.Request
Left Patch Set: diff -r c37fc54f7e208062baa619ecc43197dff1448a2c https://code.google.com/p/go Created 9 years, 7 months ago
Right Patch Set: diff -r e5c87cefb57fffc5767209542be5c4e58123e3c6 https://code.google.com/p/go Created 9 years, 7 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/http/request.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 "encoding/base64" 10 "encoding/base64"
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 {"Basic " + base64.StdEncoding.EncodeToString([]byte(":")), "", "", true }, 449 {"Basic " + base64.StdEncoding.EncodeToString([]byte(":")), "", "", true },
450 {"Basic" + base64.StdEncoding.EncodeToString([]byte("Aladdin:open sesame ")), "", "", false}, 450 {"Basic" + base64.StdEncoding.EncodeToString([]byte("Aladdin:open sesame ")), "", "", false},
451 {base64.StdEncoding.EncodeToString([]byte("Aladdin:open sesame")), "", " ", false}, 451 {base64.StdEncoding.EncodeToString([]byte("Aladdin:open sesame")), "", " ", false},
452 {"Basic ", "", "", false}, 452 {"Basic ", "", "", false},
453 {"Basic Aladdin:open sesame", "", "", false}, 453 {"Basic Aladdin:open sesame", "", "", false},
454 {`Digest username="Aladdin"`, "", "", false}, 454 {`Digest username="Aladdin"`, "", "", false},
455 } 455 }
456 456
457 func TestParseBasicAuth(t *testing.T) { 457 func TestParseBasicAuth(t *testing.T) {
458 for _, tt := range parseBasicAuthTests { 458 for _, tt := range parseBasicAuthTests {
459 » » username, password, ok := ParseBasicAuth(tt.header) 459 » » r, _ := NewRequest("GET", "http://example.com/", nil)
460 » » r.Header.Set("Authorization", tt.header)
461 » » username, password, ok := r.BasicAuth()
460 if ok != tt.ok || username != tt.username || password != tt.pass word { 462 if ok != tt.ok || username != tt.username || password != tt.pass word {
461 » » » t.Errorf("ParseBasicAuth(%s) = %#v, want %#v", tt.header , parseBasicAuthTest{username, password, ok}, 463 » » » t.Errorf("BasicAuth() = %#v, want %#v", getBasicAuthTest {username, password, ok},
462 » » » » parseBasicAuthTest{tt.username, tt.password, tt. ok}) 464 » » » » getBasicAuthTest{tt.username, tt.password, tt.ok })
463 } 465 }
464 } 466 }
465 } 467 }
466 468
467 type logWrites struct { 469 type logWrites struct {
468 t *testing.T 470 t *testing.T
469 dst *[]string 471 dst *[]string
470 } 472 }
471 473
472 func (l logWrites) WriteByte(c byte) error { 474 func (l logWrites) WriteByte(c byte) error {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 Connection: keep-alive 671 Connection: keep-alive
670 `) 672 `)
671 } 673 }
672 674
673 func BenchmarkReadRequestWrk(b *testing.B) { 675 func BenchmarkReadRequestWrk(b *testing.B) {
674 // wrk -t 1 -r 1 -c 1 http://localhost:8080/ 676 // wrk -t 1 -r 1 -c 1 http://localhost:8080/
675 benchmarkReadRequest(b, `GET / HTTP/1.1 677 benchmarkReadRequest(b, `GET / HTTP/1.1
676 Host: localhost:8080 678 Host: localhost:8080
677 `) 679 `)
678 } 680 }
LEFTRIGHT

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