Documentation ¶
Index ¶
- Constants
- func GenCA(name string) (certPEM, keyPEM []byte, err error)
- func IOCopy(w io.Writer, r *ResponseRecorder, reformatJSON bool)
- func ParseHeadersAndPostBody(headers, post string, multipartPOST bool, req *http.Request) (err error)
- func ParseSetCookies(headers http.Header) []*http.Cookie
- func PrettySize(bytes int64) string
- func TryLoadCert() (tls.Certificate, int, int)
- func WebConsoleHTTPHandler(proxy *pp.ProxyClient) func(w http.ResponseWriter, r *http.Request)
- type NullReader
- type ResponseRecorder
- func (rw *ResponseRecorder) Header() http.Header
- func (rw *ResponseRecorder) IsRedir() bool
- func (rw *ResponseRecorder) Result() *http.Response
- func (rw *ResponseRecorder) SetBody(r io.ReadCloser)
- func (rw *ResponseRecorder) Write(buf []byte) (int, error)
- func (rw *ResponseRecorder) WriteHeader(code int)
Constants ¶
const DefaultRemoteAddr = "1.2.3.4"
DefaultRemoteAddr is the default remote address to return in RemoteAddr if an explicit DefaultRemoteAddr isn't set on ResponseRecorder.
Variables ¶
This section is empty.
Functions ¶
func ParseHeadersAndPostBody ¶
func PrettySize ¶
func TryLoadCert ¶
func TryLoadCert() (tls.Certificate, int, int)
func WebConsoleHTTPHandler ¶
func WebConsoleHTTPHandler(proxy *pp.ProxyClient) func(w http.ResponseWriter, r *http.Request)
Types ¶
type NullReader ¶
type NullReader struct{}
func (*NullReader) Close ¶
func (r *NullReader) Close() error
type ResponseRecorder ¶
type ResponseRecorder struct { Code int HeaderMap http.Header Flushed bool Body io.ReadCloser // contains filtered or unexported fields }
ResponseRecorder is an implementation of http.ResponseWriter that records its mutations for later inspection in tests.
func NewRecorder ¶
func NewRecorder(callback func(bytes int64)) *ResponseRecorder
NewRecorder returns an initialized ResponseRecorder.
func (*ResponseRecorder) Header ¶
func (rw *ResponseRecorder) Header() http.Header
Header returns the response headers.
func (*ResponseRecorder) IsRedir ¶
func (rw *ResponseRecorder) IsRedir() bool
func (*ResponseRecorder) Result ¶
func (rw *ResponseRecorder) Result() *http.Response
Result returns the response generated by the handler.
The returned Response will have at least its StatusCode, Header, Body, and optionally Trailer populated. More fields may be populated in the future, so callers should not DeepEqual the result in tests.
The Response.Header is a snapshot of the headers at the time of the first write call, or at the time of this call, if the handler never did a write.
The Response.Body is guaranteed to be non-nil and Body.Read call is guaranteed to not return any error other than io.EOF.
Result must only be called after the handler has finished running.
Coyove: note this method will not dump body
func (*ResponseRecorder) SetBody ¶
func (rw *ResponseRecorder) SetBody(r io.ReadCloser)
func (*ResponseRecorder) WriteHeader ¶
func (rw *ResponseRecorder) WriteHeader(code int)
WriteHeader sets rw.Code. After it is called, changing rw.Header will not affect rw.HeaderMap.