Documentation ¶
Index ¶
- func CopyHeaders(from, to http.Header)
- func CopyHeadersWithout(from, to http.Header, exceptions ...string)
- func Error(w http.ResponseWriter, code int)
- func GetHopByHopHeaders() []string
- func ParseURLHost(u *url.URL) (host, port string, err error)
- type ContentRange
- type FlexibleResponseWriter
- func (frw *FlexibleResponseWriter) Close() error
- func (frw *FlexibleResponseWriter) Header() http.Header
- func (frw *FlexibleResponseWriter) ReadFrom(r io.Reader) (n int64, err error)
- func (frw *FlexibleResponseWriter) Write(buf []byte) (int, error)
- func (frw *FlexibleResponseWriter) WriteHeader(code int)
- type Range
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyHeaders ¶
CopyHeaders copies all headers from `from` to `to`.
func CopyHeadersWithout ¶
CopyHeadersWithout copies headers from `from` to `to` except for the `exceptions`
func Error ¶
func Error(w http.ResponseWriter, code int)
Error is short for http.Error(w, http.StatusText(code), code)
func GetHopByHopHeaders ¶
func GetHopByHopHeaders() []string
GetHopByHopHeaders returns a list of hop-by-hop headers. These should be removed when sending proxied responses to the client. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
Types ¶
type ContentRange ¶
type ContentRange struct {
Start, Length, ObjSize uint64
}
ContentRange specifies the byte range to be sent to the client.
func GetResponseRange ¶
func GetResponseRange(code int, headers http.Header) (*ContentRange, error)
GetResponseRange returns the expected response range according to either the Content-Length header for full responses or the Content-Range header for partial ones. If not enough information is present, it returns an error
func ParseResponseContentRange ¶
func ParseResponseContentRange(cr string) (*ContentRange, error)
ParseResponseContentRange parses a "Content-Range" header string. It only implements a subset of RFC 7233 - asterisks (unknown complete-length or unsatisfied-range) are treated as an error.
type FlexibleResponseWriter ¶
type FlexibleResponseWriter struct { Code int // the HTTP response code from WriteHeader Headers http.Header // the HTTP response headers BodyWriter io.WriteCloser // contains filtered or unexported fields }
FlexibleResponseWriter is an implementation of http.ResponseWriter that calls a hook function before accepting writes. The hook function's job is to inspect the current state and determine where the body should be written.
func NewFlexibleResponseWriter ¶
func NewFlexibleResponseWriter(hook func(*FlexibleResponseWriter)) *FlexibleResponseWriter
NewFlexibleResponseWriter returns an initialized FlexibleResponseWriter.
func (*FlexibleResponseWriter) Close ¶
func (frw *FlexibleResponseWriter) Close() error
Close closes the internal bodyWriter
func (*FlexibleResponseWriter) Header ¶
func (frw *FlexibleResponseWriter) Header() http.Header
Header returns the response headers.
func (*FlexibleResponseWriter) ReadFrom ¶ added in v0.1.5
func (frw *FlexibleResponseWriter) ReadFrom(r io.Reader) (n int64, err error)
ReadFrom uses io.Copy with the BoduWriter if available after writing headers and checking that the writer is set
func (*FlexibleResponseWriter) Write ¶
func (frw *FlexibleResponseWriter) Write(buf []byte) (int, error)
Write checks if a writer is initialized. If there is a body writer, it passes the arguments to it. If there isn't one, it fails.
func (*FlexibleResponseWriter) WriteHeader ¶
func (frw *FlexibleResponseWriter) WriteHeader(code int)
WriteHeader sets rw.Code and calls the hook function.
type Range ¶
type Range struct {
Start, Length uint64
}
Range specifies the byte range from a client request.
func ParseRequestRange ¶
ParseRequestRange parses a client "Range" header string as per RFC 7233.
func (Range) ContentRange ¶
ContentRange returns Range as string appropriate for usage as value of Content-Range header.