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

Delta Between Two Patch Sets: src/pkg/http/httptest/recorder.go

Issue 4245064: code review 4245064: http: add Hijacker type; remove Hijack from ResponseWriter (Closed)
Left Patch Set: Created 13 years ago
Right Patch Set: diff -r 1ba6a90e1545 https://go.googlecode.com/hg/ Created 13 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:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/http/server.go » ('j') | src/pkg/http/server.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 // The httptest package provides utilities for HTTP testing. 5 // The httptest package provides utilities for HTTP testing.
6 package httptest 6 package httptest
7 7
8 import ( 8 import (
9 "bufio"
10 "bytes" 9 "bytes"
11 "http" 10 "http"
12 "io"
13 "os" 11 "os"
14 ) 12 )
15 13
16 // ResponseRecorder is an implementation of http.ResponseWriter that 14 // ResponseRecorder is an implementation of http.ResponseWriter that
17 // records its mutations for later inspection in tests. 15 // records its mutations for later inspection in tests.
18 //
19 // Note that Hijack is not implemented and simply panics.
20 type ResponseRecorder struct { 16 type ResponseRecorder struct {
21 Code int // the HTTP response code from WriteHeader 17 Code int // the HTTP response code from WriteHeader
22 Header http.Header // if non-nil, the headers to populate 18 Header http.Header // if non-nil, the headers to populate
23 Body *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to 19 Body *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to
24 Flushed bool 20 Flushed bool
25 21
26 FakeRemoteAddr string // the fake RemoteAddr to return, or "" for Defaul tRemoteAddr 22 FakeRemoteAddr string // the fake RemoteAddr to return, or "" for Defaul tRemoteAddr
27 FakeUsingTLS bool // whether to return true from the UsingTLS method 23 FakeUsingTLS bool // whether to return true from the UsingTLS method
28 } 24 }
29 25
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 70
75 // WriteHeader sets rw.Code. 71 // WriteHeader sets rw.Code.
76 func (rw *ResponseRecorder) WriteHeader(code int) { 72 func (rw *ResponseRecorder) WriteHeader(code int) {
77 rw.Code = code 73 rw.Code = code
78 } 74 }
79 75
80 // Flush sets rw.Flushed to true. 76 // Flush sets rw.Flushed to true.
81 func (rw *ResponseRecorder) Flush() { 77 func (rw *ResponseRecorder) Flush() {
82 rw.Flushed = true 78 rw.Flushed = true
83 } 79 }
84
85 // Hijack is not implemented in ResponseRecorder and instead panics.
86 func (rw *ResponseRecorder) Hijack() (io.ReadWriteCloser, *bufio.ReadWriter, os. Error) {
87 panic("Hijack not implemented in ResponseRecorder")
88 }
LEFTRIGHT

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