simplehttp

package
v0.0.0-...-7db4253 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompTime

func CompTime(t1, t2 int64) int64

func ConnPath

func ConnPath(args ...string) string

func Response

func Response(conn net.Conn, code int, codeCommand string, data []byte, contextType string) error

func Str2int64

func Str2int64(str string) int64

Types

type Handler

type Handler interface {
	ServeHTTP(*HttpResponse, *HttpRequest)
}

type HttpClient

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

func NewHttpClient

func NewHttpClient(url string, keepAlive bool) *HttpClient

func (*HttpClient) Download

func (me *HttpClient) Download(uri string, fh *os.File) (int64, error)

func (*HttpClient) Get

func (me *HttpClient) Get(uri string) ([]byte, error)

func (*HttpClient) GetBody

func (me *HttpClient) GetBody() []byte

func (*HttpClient) GetHeader

func (me *HttpClient) GetHeader(name string) string

func (*HttpClient) GetHeaders

func (me *HttpClient) GetHeaders() map[string][]string

func (*HttpClient) GetStatusCode

func (me *HttpClient) GetStatusCode() int

func (*HttpClient) GetTimeout

func (me *HttpClient) GetTimeout(uri string, second int) ([]byte, error)

func (*HttpClient) Post

func (me *HttpClient) Post(uri string, data []byte) ([]byte, error)

func (*HttpClient) Put

func (me *HttpClient) Put(uri string, data []byte) ([]byte, error)

func (*HttpClient) SetCert

func (me *HttpClient) SetCert(ca string, cert, key string, auth bool)

func (*HttpClient) SetConnTimeout

func (me *HttpClient) SetConnTimeout(ms int)

func (*HttpClient) SetHttpHeader

func (me *HttpClient) SetHttpHeader(name string, value string)

func (*HttpClient) SetProxy

func (me *HttpClient) SetProxy(proxy string)

func (*HttpClient) SetTimeout

func (me *HttpClient) SetTimeout(v int)

func (*HttpClient) SetTotalTimeout

func (me *HttpClient) SetTotalTimeout(ms int)

func (*HttpClient) SetUserAgent

func (me *HttpClient) SetUserAgent(agent string)

type HttpInstance

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

func (*HttpInstance) Form

func (me *HttpInstance) Form(name string) (string, bool)

func (*HttpInstance) GetRequestData

func (me *HttpInstance) GetRequestData() []byte

func (*HttpInstance) GetStatus

func (me *HttpInstance) GetStatus() HttpStatus

func (*HttpInstance) Write

func (me *HttpInstance) Write(data []byte)

func (*HttpInstance) WriteString

func (me *HttpInstance) WriteString(str string)

type HttpRequest

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

func (*HttpRequest) Form

func (me *HttpRequest) Form(name string) (string, bool)

func (*HttpRequest) GetBody

func (me *HttpRequest) GetBody() []byte

func (*HttpRequest) GetHeader

func (me *HttpRequest) GetHeader(name string) string

func (*HttpRequest) GetHeaders

func (me *HttpRequest) GetHeaders() url.Values

func (*HttpRequest) GetStatus

func (me *HttpRequest) GetStatus() HttpStatus

func (*HttpRequest) LocalIP

func (me *HttpRequest) LocalIP() string

func (*HttpRequest) Method

func (me *HttpRequest) Method() string

func (*HttpRequest) ParseForm

func (me *HttpRequest) ParseForm()

func (*HttpRequest) RemoteAddr

func (me *HttpRequest) RemoteAddr() string

func (*HttpRequest) RemoteIP

func (me *HttpRequest) RemoteIP() string

func (*HttpRequest) RequestURI

func (me *HttpRequest) RequestURI() string

type HttpResponse

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

func (*HttpResponse) DeleteHttpHeader

func (me *HttpResponse) DeleteHttpHeader(name string)

func (*HttpResponse) GetHeader

func (me *HttpResponse) GetHeader(name string) string

func (*HttpResponse) ResetHttpHeader

func (me *HttpResponse) ResetHttpHeader()

func (*HttpResponse) SetHttpHeader

func (me *HttpResponse) SetHttpHeader(name string, value string)

func (*HttpResponse) SetStatusCode

func (me *HttpResponse) SetStatusCode(code int)

func (*HttpResponse) Write

func (me *HttpResponse) Write(buf []byte)

func (*HttpResponse) WriteString

func (me *HttpResponse) WriteString(str string)

type HttpServer

type HttpServer struct {
	Router    RouterMgr
	OnConnect func(inst *HttpInstance, conn *net.TCPConn)
	/* bAttach:true 不处理http请求,有调用处理连接 */
	OnAccept func(conn net.Conn, bAttach *bool)
	// contains filtered or unexported fields
}

func NewHttpServer

func NewHttpServer(bind string) *HttpServer

func (*HttpServer) AddBind

func (me *HttpServer) AddBind(name string, bind string)

func (*HttpServer) GetRouter

func (me *HttpServer) GetRouter() *RouterMgr

func (*HttpServer) RelayTCPConnect

func (me *HttpServer) RelayTCPConnect(conn net.Conn, remoteAddr string) error

func (*HttpServer) SetDebug

func (me *HttpServer) SetDebug(debug bool)

func (*HttpServer) Start

func (me *HttpServer) Start() error

func (*HttpServer) Stop

func (me *HttpServer) Stop()

type HttpStatus

type HttpStatus struct {
	Code   int
	Method string
	URI    string
}

type Router

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

type RouterMgr

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

func (*RouterMgr) AddRouter

func (me *RouterMgr) AddRouter(path string, handler interface{}, absPath bool, args ...string) *Router

AddRouter /*

path: uri@name uri: http uri name: server name, optional

handler:

func(*HttpResponse, *HttpRequest)
func(*HttpInstance)

func (*RouterMgr) AddRouterFunc

func (me *RouterMgr) AddRouterFunc(path string, handler func(*HttpResponse, *HttpRequest), absPath bool, args ...string) *Router

func (*RouterMgr) GetRouter

func (me *RouterMgr) GetRouter(path string) (*Router, string)

Jump to

Keyboard shortcuts

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