httputils

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(r *http.Request) string

ClientIP 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。

func GetResponseBodyFormUrl

func GetResponseBodyFormUrl(method, reqUrl, proxyUrl string, customHeader map[string]string, reqBody io.Reader) ([]byte, error)

func HttpProxyClient

func HttpProxyClient(rawURL string) *http.Client

HttpProxyClient local proxy: "http://127.0.0.1:7890"

func NewRequestHeaders added in v0.2.0

func NewRequestHeaders() requestHeaders

func QueryStringDecoder4Request added in v0.2.0

func QueryStringDecoder4Request(r *http.Request, val any) error

func QueryStringEncoder added in v0.2.6

func QueryStringEncoder(val any) (string, error)

func RemoteIP

func RemoteIP(r *http.Request) string

RemoteIP 通过 RemoteAddr 获取 IP 地址, 只是一个快速解析方法。

func SubmitFormData added in v0.1.7

func SubmitFormData(reqUrl, proxyUrl string, fileFields, formData map[string]string) ([]byte, error)

SubmitFormData 提交表单,上传文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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