httpclient

package module
v0.0.0-...-4643a83 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MulanPSL-2.0 Imports: 8 Imported by: 13

README

HttpClient

💡 Introduction

HTTP Client for SiYuan.

🙏 Acknowledgement

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseIdleConnections

func CloseIdleConnections()

func GetCloudFileClient2Min

func GetCloudFileClient2Min() *http.Client

func NewBrowserRequest

func NewBrowserRequest() (ret *req.Request)

func NewCloudFileRequest2m

func NewCloudFileRequest2m() *req.Request

func NewCloudRequest30s

func NewCloudRequest30s() *req.Request

func NewTransport

func NewTransport(skipTlsVerify bool) *http.Transport

func NewUserAgentClient

func NewUserAgentClient(base http.RoundTripper) *http.Client

NewUserAgentClient 返回带 SiYuan UA 注入的 *http.Client。 base 为 nil 时用 NewTransport(false) 作底座。调用方可自行设置返回 client 的 Timeout。

func NewUserAgentRoundTripper

func NewUserAgentRoundTripper(base http.RoundTripper) http.RoundTripper

NewUserAgentRoundTripper 返回带 SiYuan UA 注入的 RoundTripper。 base 为 nil 时回退到 http.DefaultTransport。适用于需要在 transport 层叠加自定义逻辑的场景(如 MCP 自定义 header)。

func ProxyFromEnvironment

func ProxyFromEnvironment(req *http.Request) (*url.URL, error)

func SetUserAgent

func SetUserAgent(siyuanUA string)

Types

type UserAgentTransport

type UserAgentTransport struct {
	Base http.RoundTripper
}

UserAgentTransport 在出站请求上注入 SiYuan User-Agent,统一内核出网身份标识。 使用 Set 覆盖,会替换请求上已有的 UA(如 aws SDK 构造的含架构、Go 版本等的长 UA 串), 便于第三方服务端按 SiYuan/ 前缀稳定识别并加白名单。 Base 为底座 transport,负责实际的连接、代理、TLS 等配置。

func (*UserAgentTransport) RoundTrip

func (t *UserAgentTransport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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