{"modulePath":"github.com/Mathious6/httpkit","version":"v0.0.0-20250723215844-55768b698fa7","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package httpkit\n\n## Constants\n\n```go\nconst CookieExpired = -1\n```\n\n## Variables\n\n```go\nvar DefaultBadPinHandler = func(req *http.Request) {\n\tfmt.Println(\"this is the default bad pin handler\")\n}\n```\n\n```go\nvar DefaultOptions = []HttpClientOption{\n\tWithTimeoutSeconds(DefaultTimeoutSeconds),\n\tWithClientProfile(profiles.DefaultClientProfile),\n\tWithRandomTLSExtensionOrder(),\n\tWithNotFollowRedirects(),\n}\n```\n\n```go\nvar DefaultTimeoutSeconds = 30\n```\n\n```go\nvar ErrBadPinDetected = errors.New(\"bad ssl pin detected\")\n```\n\n```go\nvar H2SettingsMap = map[string]http2.SettingID{\n\t\"HEADER_TABLE_SIZE\":      http2.SettingHeaderTableSize,\n\t\"ENABLE_PUSH\":            http2.SettingEnablePush,\n\t\"MAX_CONCURRENT_STREAMS\": http2.SettingMaxConcurrentStreams,\n\t\"INITIAL_WINDOW_SIZE\":    http2.SettingInitialWindowSize,\n\t\"MAX_FRAME_SIZE\":         http2.SettingMaxFrameSize,\n\t\"MAX_HEADER_LIST_SIZE\":   http2.SettingMaxHeaderListSize,\n\t\"UNKNOWN_SETTING_7\":      0x7,\n\t\"UNKNOWN_SETTING_8\":      0x8,\n\t\"UNKNOWN_SETTING_9\":      0x9,\n}\n```\n\n## Functions\n\n```go\nfunc GetSpecFactoryFromJa3String(ja3String string, supportedSignatureAlgorithms, supportedDelegatedCredentialsAlgorithms, supportedVersions, keyShareCurves, supportedProtocolsALPN, supportedProtocolsALPS []string, echCandidateCipherSuites []CandidateCipherSuites, candidatePayloads []uint16, certCompressionAlgorithms []string, recordSizeLimit uint16) (func() (tls.ClientHelloSpec, error), error)\n```\n\n## Types\n\n```go\ntype BadPinHandlerFunc func(req *http.Request)\n```\n\n```go\ntype CandidateCipherSuites struct {\n\tKdfId  string\n\tAeadId string\n}\n```\n\n```go\ntype CertificatePinner interface {\n\tPin(conn *tls.UConn, host string) error\n}\n```\n\n```go\nfunc NewCertificatePinner(certificatePins map[string][]string) (CertificatePinner, error)\n```\n\n```go\ntype ContextKeyHeader struct{}\n```\nUsers of context.WithValue should define their own types for keys\n\n```go\ntype CookieJar interface {\n\thttp.CookieJar\n\tCookiesMap() map[string][]*http.Cookie\n\tCookie(u *url.URL, name string) *http.Cookie\n}\n```\nCookieJar is the interface that wraps the basic CookieJar methods, including additional helpers.\n\n```go\nfunc NewCookieJar(options ...CookieJarOption) CookieJar\n```\nNewCookieJar creates a new empty cookie jar with the given options. Returns nil if the underlying cookiejar.Jar cannot be created.\n\n```go\ntype CookieJarOption func(config *cookieJarConfig)\n```\nCookieJarOption is a function that modifies the configuration of a cookieJar.\n\n```go\nfunc WithAllowEmpty() CookieJarOption\n```\nWithAllowEmpty returns a CookieJarOption that allows empty cookies in the jar (default: false). Note: this is not recommended as empty cookies are usually not valid.\n\n```go\nfunc WithDebugLogger() CookieJarOption\n```\nWithDebugLogger returns a CookieJarOption that enables debug logging for the cookie jar.\n\n```go\nfunc WithLogger(logger Logger) CookieJarOption\n```\nWithLogger returns a CookieJarOption that sets a custom logger for the cookie jar.\n\n```go\nfunc WithSkipExisting() CookieJarOption\n```\nWithSkipExisting returns a CookieJarOption that skips existing cookies in the jar (default: false). This is useful when you want to add new cookies without overwriting existing ones.\n\n```go\ntype HttpClient interface {\n\tGetFlowId() string\n\n\tGetCookies(u *url.URL) []*http.Cookie\n\tSetCookies(u *url.URL, cookies []*http.Cookie)\n\tSetCookieJar(jar http.CookieJar)\n\tGetCookieJar() http.CookieJar\n\n\tSetProxy(proxyUrl string) error\n\tGetProxy() string\n\n\tSetFollowRedirect(followRedirect bool)\n\tGetFollowRedirect() bool\n\tCloseIdleConnections()\n\n\tDo(req *http.Request) (*http.Response, error)\n\tDoWithProxy(req *http.Request, proxyUrl string) (*http.Response, error)\n\n\tGet(url string) (resp *http.Response, err error)\n\tHead(url string) (resp *http.Response, err error)\n\tPost(url, contentType string, body io.Reader) (resp *http.Response, err error)\n\n\tGetBandwidthTracker() bandwidth.BandwidthTracker\n}\n```\n\n```go\nfunc NewHttpClient(logger Logger, options ...HttpClientOption) (HttpClient, error)\n```\nNewHttpClient constructs a new HTTP client with the given logger and client options.\n\n```go\nfunc ProvideDefaultClient(logger Logger) (HttpClient, error)\n```\n\n```go\ntype HttpClientOption func(config *httpClientConfig)\n```\n\n```go\nfunc WithBandwidthTracker() HttpClientOption\n```\nWithBandwidthTracker configures a client to track the bandwidth used by the client.\n\n```go\nfunc WithCatchPanics() HttpClientOption\n```\nWithCatchPanics configures a client to catch all go panics happening during a request and not print the stacktrace.\n\n```go\nfunc WithCertificatePinning(certificatePins map[string][]string, handlerFunc BadPinHandlerFunc) HttpClientOption\n```\nWithCertificatePinning enables SSL Pinning for the client and will throw an error if the SSL Pin is not matched. Please refer to [https://github.com/tam7t/hpkp/#examples](https://github.com/tam7t/hpkp/#examples) in order to see how to generate pins. The certificatePins are a map with the host as key. You can provide a BadPinHandlerFunc or nil as second argument. This function will be executed once a bad ssl pin is detected. BadPinHandlerFunc has to be defined like this: func(req \\*http.Request){}\n\n```go\nfunc WithCharlesProxy(host string, port string) HttpClientOption\n```\nWithCharlesProxy configures the HTTP client to use a local running charles as proxy.\n\nhost and port can be empty, then default 127.0.0.1 and port 8888 will be used\n\n```go\nfunc WithClientProfile(clientProfile profiles.ClientProfile) HttpClientOption\n```\nWithClientProfile configures a TLS client to use the specified client profile.\n\n```go\nfunc WithConnectHeaders(headers http.Header) HttpClientOption\n```\nWithConnectHeaders configures a client to use the specified headers for the CONNECT request.\n\n```go\nfunc WithCookieJar(jar http.CookieJar) HttpClientOption\n```\nWithCookieJar configures a HTTP client to use the specified cookie jar.\n\n```go\nfunc WithCustomRedirectFunc(redirectFunc func(req *http.Request, via []*http.Request) error) HttpClientOption\n```\nWithCustomRedirectFunc configures an HTTP client to use a custom redirect func. The redirect func have to look like that: func(req \\*http.Request, via \\[]\\*http.Request) error Please only provide a custom redirect function if you know what you are doing. Check docs on net/http.Client CheckRedirect\n\n```go\nfunc WithDebug() HttpClientOption\n```\nWithDebug configures a client to log debugging information.\n\n```go\nfunc WithDefaultHeaders(defaultHeaders http.Header) HttpClientOption\n```\nWithDefaultHeaders configures a TLS client to use a set of default headers if none are specified on the request.\n\n```go\nfunc WithDialer(dialer net.Dialer) HttpClientOption\n```\nWithDialer configures an HTTP client to use the specified dialer. This allows the use of a custom DNS resolver\n\n```go\nfunc WithDisableIPV4() HttpClientOption\n```\nWithDisableIPV4 configures a dialer to use tcp6 network argument\n\n```go\nfunc WithDisableIPV6() HttpClientOption\n```\nWithDisableIPV6 configures a dialer to use tcp4 network argument\n\n```go\nfunc WithFlowId(flowId string) HttpClientOption\n```\nWithFlowId configures a HTTP client to use the specified flow id.\n\n```go\nfunc WithForceHttp1() HttpClientOption\n```\nWithForceHttp1 configures a client to force HTTP/1.1 as the used protocol.\n\n```go\nfunc WithInsecureSkipVerify() HttpClientOption\n```\nWithInsecureSkipVerify configures a client to skip SSL certificate verification.\n\n```go\nfunc WithLocalAddr(localAddr net.TCPAddr) HttpClientOption\n```\nWithLocalAddr configures an HTTP client to use the specified local address.\n\n```go\nfunc WithNotFollowRedirects() HttpClientOption\n```\nWithNotFollowRedirects configures an HTTP client to not follow HTTP redirects.\n\n```go\nfunc WithProxyDialerFactory(proxyDialerFactory ProxyDialerFactory) HttpClientOption\n```\nWithProxyDialerFactory configures an HTTP client to use a custom proxyDialerFactory instead of newConnectDialer(). This allows to implement custom proxy dialer use cases\n\n```go\nfunc WithProxyUrl(proxyUrl string) HttpClientOption\n```\nWithProxyUrl configures a HTTP client to use the specified proxy URL.\n\nproxyUrl should be formatted as:\n\n\t\"http://user:pass@host:port\"\n\n```go\nfunc WithRandomTLSExtensionOrder() HttpClientOption\n```\nWithRandomTLSExtensionOrder configures a TLS client to randomize the order of TLS extensions being sent in the ClientHello.\n\nPlacement of GREASE and padding is fixed and will not be affected by this.\n\n```go\nfunc WithServerNameOverwrite(serverName string) HttpClientOption\n```\nWithServerNameOverwrite configures a TLS client to overwrite the server name being used for certificate verification and in the client hello. This option does only work properly if WithInsecureSkipVerify is set to true in addition\n\n```go\nfunc WithTimeoutMilliseconds(timeout int) HttpClientOption\n```\nWithTimeoutMilliseconds configures an HTTP client to use the specified request timeout.\n\ntimeout is the request timeout in milliseconds.\n\n```go\nfunc WithTimeoutSeconds(timeout int) HttpClientOption\n```\nWithTimeoutSeconds configures an HTTP client to use the specified request timeout.\n\ntimeout is the request timeout in seconds.\n\n```go\nfunc WithTransportOptions(transportOptions *TransportOptions) HttpClientOption\n```\nWithTransportOptions configures a client to use the specified transport options.\n\n```go\ntype Logger interface {\n\tDebug(format string, args ...any)\n\tInfo(format string, args ...any)\n\tWarn(format string, args ...any)\n\tError(format string, args ...any)\n}\n```\n\n```go\nfunc NewDebugLogger(logger Logger) Logger\n```\n\n```go\nfunc NewLogger() Logger\n```\n\n```go\nfunc NewNoopLogger() Logger\n```\n\n```go\ntype ProxyDialerFactory func(proxyUrlStr string, timeout time.Duration, localAddr *net.TCPAddr, connectHeaders http.Header, logger Logger) (proxy.ContextDialer, error)\n```\n\n```go\ntype TransportOptions struct {\n\t// KeyLogWriter is an io.Writer that the TLS client will use to write the\n\t// TLS master secrets to. This can be used to decrypt TLS connections in\n\t// Wireshark and other applications.\n\tKeyLogWriter io.Writer\n\t// IdleConnTimeout is the maximum amount of time an idle (keep-alive)\n\t// connection will remain idle before closing itself. Zero means no limit.\n\tIdleConnTimeout *time.Duration\n\t// RootCAs is the set of root certificate authorities used to verify\n\t// the remote server's certificate.\n\tRootCAs                *x509.CertPool\n\tMaxIdleConns           int\n\tMaxIdleConnsPerHost    int\n\tMaxConnsPerHost        int\n\tMaxResponseHeaderBytes int64 // Zero means to use a default limit.\n\tWriteBufferSize        int   // If zero, a default (currently 4KB) is used.\n\tReadBufferSize         int   // If zero, a default (currently 4KB) is used.\n\tDisableKeepAlives      bool\n\tDisableCompression     bool\n}\n```\n\n","path":"github.com/Mathious6/httpkit","name":"httpkit","synopsis":"","isRedistributable":true}
