標籤:http io ar os 使用 sp for 檔案 資料
兩周沒寫東西了,主要是在學習一點C,參考 webbench 寫了個工具。剛剛寫完,也不知道好不好用,同學們有興趣也幫我測一測,提點意見。
項目位於 https://github.com/heiing/hb
複製下來後,使用 make 編譯即可。
./hb [OPTIONS] URLOPTIONS: -h | --help Print this information and exit. -v | --version Display program version and exit. -c | --clients <n> Run <n> clients, default one. -t | --time <second> Run <second> seconds, default 30. -m | --method <n> Use HTTP method, default GET: GET,POST,PUT,DELETE,HEAD,TRACE,PATCH PROPFIND,COPY,MOVE -p | --protocol <n> Use HTTP protocol, default 2:\n" 0 - HTTP/0.9 1 - HTTP/1.0 2 - HTTP/1.1 -f | --file <path> Use file for POST/PUT method. -P | --proxy <server:port> Use proxy for request.
樣本:
./hb -m POST -f postdata.txt http://example.com/foo
可以通過 -f 參數指定請求的資料,資料檔案為 http 協議格式,使用一個空行分隔 head 和 body。不需要頭部時,以一個空行開始。例如:
name=hb&version=0.0.1
包含頭部的樣本:
User-Agent: my agent 1.0Content-Type: application/x-www-form-urlencodedCookie: PHPSESSID=1234567890123456name=hb&version=0.0.1
當程式運行結束後,按響應碼統計請求數。
hb:一個簡單的 http/web bench 工具