protocol

package
v0.0.0-...-ad97950 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK = 200

	StatusBadRequest = 400
	StatusForbidden  = 403

	StatusNotImplemented = 501
	StatusBadGateway     = 502
)
View Source
const (
	EncodingGzip = "gzip"
	EncodingZlib = "zlib"
)
View Source
const MethodConnect = "CONNECT"

Variables

View Source
var StatusText = map[int]string{
	StatusOK: "OK",

	StatusBadRequest: "Bad Request",
	StatusForbidden:  "Forbidden",

	StatusNotImplemented: "Not implemented",
	StatusBadGateway:     "Bad Gateway",
}

Functions

func ReadLine

func ReadLine(reader *bufio.Reader) (string, error)

func WriteLine

func WriteLine(writer io.Writer, line string) error

Types

type Error

type Error struct {
	Status int
	Error  error
}
type Header struct {
	Key, Value string
}

type MessageBase

type MessageBase struct {
	Headers []Header
	Body    *Pipe
}

func (*MessageBase) Chunked

func (message *MessageBase) Chunked() bool

func (*MessageBase) DecodedBodyReader

func (message *MessageBase) DecodedBodyReader() (io.ReadCloser, error)

func (*MessageBase) DecodedBodyWriter

func (message *MessageBase) DecodedBodyWriter() io.WriteCloser

func (*MessageBase) DeleteHeader

func (message *MessageBase) DeleteHeader(key string)

func (*MessageBase) Header

func (message *MessageBase) Header(key string) (string, bool)

func (*MessageBase) ReadFrom

func (message *MessageBase) ReadFrom(reader *bufio.Reader) error

func (*MessageBase) SetChunked

func (message *MessageBase) SetChunked(value bool)

func (*MessageBase) SetHeader

func (message *MessageBase) SetHeader(key, value string)

func (*MessageBase) WriteTo

func (message *MessageBase) WriteTo(writer io.Writer) error

type Pipe

type Pipe struct {
	Reader *io.PipeReader
	Writer *io.PipeWriter
}

func NewPipe

func NewPipe() *Pipe

type Request

type Request struct {
	Method, Url, Protocol string
	MessageBase
}

func (*Request) ReadFrom

func (request *Request) ReadFrom(conn net.Conn) error

func (*Request) WriteTo

func (request *Request) WriteTo(conn net.Conn) error

type Response

type Response struct {
	Protocol string
	Code     int
	Reason   string
	MessageBase
}

func (*Response) ReadFrom

func (response *Response) ReadFrom(conn net.Conn) error

func (*Response) WriteTo

func (response *Response) WriteTo(conn net.Conn) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL