http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRLF = []byte{13, 10}

"/r/n"

View Source
var SEP = []byte{58, 32}

": "

Functions

func AddRouter

func AddRouter(Url []byte, method HttpMethod, handler func(*HttpRequest, *HttpResponse)) error

func DefaultGETHandler

func DefaultGETHandler(request *HttpRequest, response *HttpResponse, phpPlugin *php.Plugin)

Default GET method

root/URL

func DefaultHEADHandler

func DefaultHEADHandler(request *HttpRequest, response *HttpResponse)

Default HEAD method

func DefaultPOSTHandler

func DefaultPOSTHandler(request *HttpRequest, response *HttpResponse)

Default POST method

func Handler

func Handler(rawPacket []byte, phpPlugin *php.Plugin) (rep *stream.HttpStream, isKeepAlive bool)

HTTP包处理

func RemoveRouter

func RemoveRouter(Url []byte, method HttpMethod) error

Types

type HttpMethod

type HttpMethod uint8

HttpMethod

GET POST HEAD
const (
	GET  HttpMethod = 71
	POST HttpMethod = 80
	HEAD HttpMethod = 72
)

type HttpRequest

type HttpRequest struct {
	// contains filtered or unexported fields
}

HTTP请求

func (*HttpRequest) GetAllParamKey

func (req *HttpRequest) GetAllParamKey() []string

获取request的所有参数名

func (*HttpRequest) GetParam

func (req *HttpRequest) GetParam(key string) string

获取request的参数

type HttpResponse

type HttpResponse struct {
	// contains filtered or unexported fields
}

HTTP返回

func (*HttpResponse) SetHeader

func (rep *HttpResponse) SetHeader(key string, value string)

设置response的首部

func (*HttpResponse) Write

func (rep *HttpResponse) Write(Data ...interface{})

Response Content 写入接口

type HttpStateCode

type HttpStateCode uint16

HttpStateCode

const (
	OK                  HttpStateCode = 200
	PartialContent      HttpStateCode = 206
	BadRequest          HttpStateCode = 400
	Unauthorized        HttpStateCode = 401
	Forbidden           HttpStateCode = 403
	NotFound            HttpStateCode = 404
	InternalServerError HttpStateCode = 500
	ServerUnavailable   HttpStateCode = 503
)

Jump to

Keyboard shortcuts

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