Fhttp
The f stands for fly
Install / Use
/learn @useflyent/FhttpREADME
fhttp
Features
Ordered Headers
The package allows for both pseudo header order and normal header order. Most of the code is from this this Pull Request.
Note on HTTP/1.1 header order Although the header key is capitalized, the header order slice must be in lowercase.
req.Header = http.Header{
"X-NewRelic-ID": {"12345"},
"x-api-key": {"ABCDE12345"},
"MESH-Commerce-Channel": {"android-app-phone"},
"mesh-version": {"cart=4"},
"X-Request-Auth": {"hawkHeader"},
"X-acf-sensor-data": {"3456"},
"Content-Type": {"application/json; charset=UTF-8"},
"Accept": {"application/json"},
"Transfer-Encoding": {"chunked"},
"Host": {"example.com"},
"Connection": {"Keep-Alive"},
"Accept-Encoding": {"gzip"},
HeaderOrderKey: {
"x-newrelic-id",
"x-api-key",
"mesh-commerce-channel",
"mesh-version",
"user-agent",
"x-request-auth",
"x-acf-sensor-data",
"transfer-encoding",
"content-type",
"accept",
"host",
"connection",
"accept-encoding",
},
PHeaderOrderKey: {
":method",
":path",
":authority",
":scheme",
},
}
Connection settings
fhhtp has Chrome-like connection settings, as shown below:
SETTINGS_HEADER_TABLE_SIZE = 65536 (2^16)
SETTINGS_ENABLE_PUSH = 1
SETTINGS_MAX_CONCURRENT_STREAMS = 1000
SETTINGS_INITIAL_WINDOW_SIZE = 6291456
SETTINGS_MAX_FRAME_SIZE = 16384 (2^14)
SETTINGS_MAX_HEADER_LIST_SIZE = 262144 (2^18)
The default net/http settings, on the other hand, are the following:
SETTINGS_HEADER_TABLE_SIZE = 4096
SETTINGS_ENABLE_PUSH = 0
SETTINGS_MAX_CONCURRENT_STREAMS = unlimited
SETTINGS_INITIAL_WINDOW_SIZE = 4194304
SETTINGS_MAX_FRAME_SIZE = 16384
SETTINGS_MAX_HEADER_LIST_SIZE = 10485760
The ENABLE_PUSH implementation was merged from this Pull Request.
gzip, deflate, and br encoding
gzip, deflate, and br encoding are all supported by the package.
Pseudo header order
fhttp supports pseudo header order for http2, helping mitigate fingerprinting. You can read more about how it works here.
Backward compatible with net/http
Although this library is an extension of net/http, it is also meant to be backward compatible. Replacing
import (
"net/http"
)
with
import (
http "github.com/useflyent/fhttp"
)
SHOULD not break anything.
Versatile Content-Length and Transfer-Encoding headers
fhttp user to set custom Content-Length and Transfer-Encoding headers of all types.
To set an empty Content-Length header
req.Header = http.Header{
"Content-Length": {http.ContentLengthEmpty},
}
To ignore setting the Content-Length header
req.Header = http.Header{
"Content-Length": {http.ContentLengthDelete},
}
Any Content-Length or Transfer-Encoding headers set will be prioritized and fhttp will not set proper Content-length or Transfer-Encoding headers
Credits
Special thanks to the following people for helping me with this project.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
