reqrio
v0.2.0
Published
A lightweight, high concurrency HTTP request library
Maintainers
Readme
reqrio is an HTTP request library designed for fast, simple, and convenient HTTP request usage.
Features: Low copy, high concurrency, low overhead
Supports TLS fingerprinting, which can be configured via hexadecimal, Ja3, or Ja4 TLS handshake settings (* subscription only*).
Ensures request header order (see Request Header Order Table), consistent with browsers.
Uses BoringSSL to implement TLS, consistent with browsers like Chrome and Edge.
Low-Copy
reqrio is a low copy request sending engine used to efficiently encrypt user or file data over TLS and send it to TCP. reqrio
Convert user input data such as form data, json, bytes, text, etc. into bytes for storage, and only copy once during TLS encryption, while only the data is processed in other stages
Borrow (borrowing). File uploads are read through into_deader to reduce memory overhead
Data ┌────────┐encode->bytes ┌──────────┐ ┌──────────┐
User ──────►│ │────────────►│ │ │ │
│ ScReq │ │ Request │ copy slice │ fragment │ write ┌───────┐
│ AcReq │ │ borrow │───────────►│ TLS │─────►│ TCP │
Files │(Engine)│ into_reader │ buffer │ │ Encrypt │ └───────┘
User ──────►│ │────────────►│ │ │ │
└────────┘ └──────────┘ └──────────┘Request Header Order Table
| No. | HTTP/2.0 | HTTP/1.1 | |:----|:----------------------------|:--------------------------| | 1 | cache-control | Host | | 2 | sec-ch-ua | Connection | | 3 | sec-ch-ua-mobile | Content-Length | | 4 | sec-ch-ua-full-version | Authorization | | 5 | sec-ch-ua-arch | Content-Type | | 6 | sec-ch-ua-platform | Cache-Control | | 7 | sec-ch-ua-platform-version | sec-ch-ua | | 8 | sec-ch-ua-model | sec-ch-ua-mobile | | 9 | sec-ch-ua-bitness | sec-ch-ua-platform | | 10 | sec-ch-ua-full-version-list | Upgrade-Insecure-Requests | | 11 | upgrade-insecure-requests | User-Agent | | 12 | user-agent | Accept | | 13 | accept | Sec-Fetch-Site | | 14 | origin | Sec-Fetch-Mode | | 15 | sec-fetch-site | Sec-Fetch-User | | 16 | sec-fetch-mode | Sec-Fetch-Dest | | 17 | sec-fetch-user | Sec-Fetch-Storage-Access | | 18 | sec-fetch-dest | Referer | | 19 | sec-fetch-storage-access | Accept-Encoding | | 20 | referer | Accept-Language | | 21 | accept-encoding | Cookie | | 22 | accept-language | Origin | | 23 | cookie | | | 24 | priority | | | | //unknown | | | 25 | content-encoding | | | 26 | content-type | | | 27 | authorization | | | 28 | content-type | |
Usage examples:
- Http Example
const {Session, ALPN} = require("reqrio")
let session = new Session(ALPN.HTTP11)
session.set_headers({
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Cookie": "__guid=15015764.1071255116101212729.1764940193317.2156; env_webp=1; _S=pvc5q7leemba50e4kn4qis4b95; QiHooGUID=4C8051464B2D97668E3B21198B9CA207.1766289287750; count=1; so-like-red=2; webp=1; so_huid=114r0SZFiQcJKtA38GZgwZg%2Fdit1cjUGuRcsIL2jTn4%2FE%3D; __huid=114r0SZFiQcJKtA38GZgwZg%2Fdit1cjUGuRcsIL2jTn4%2FE%3D; gtHuid=1",
"Host": "m.so.com",
"Pragma": "no-cache",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": 1,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0",
"sec-ch-ua": '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"'
})
session.set_url('https://m.so.com')
let resp = session.get()
console.log(resp.status_code())
session.close()
- WebSocket Example
const {Websocket} = require('index')
let ws = new Websocket();
ws.set_url("wss://api.github.com")
ws.add_header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0")
ws.set_proxy("http://127.0.0.1:7878")
ws.open()
while (true) {
frame = ws.read()
console.log(frame)
}
