Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package worker
import (
"context"
"fmt"
"regexp"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -210,7 +211,16 @@ func (w *Worker) runWorker() {
req.SetHeader("Connection", "close")
}

req.CalculateContentLength()
// 目前样本中没有使用Transfer-Encoding: chunked的,但是为了自定义样本需要更小心地设置Content-Length
// 参考: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Length
is_http1_1, err := regexp.Match("[A-Z]+ [^ ]+ HTTP/1.1", req.RequestLine)
if err != nil {
job.Result.Err = fmt.Sprintf("parse request failed, error: %s", err)
return
}
if is_http1_1 && !strings.Contains(req.GetHeader("Transfer-Encoding"), "chunked") {
req.CalculateContentLength()
}

start := time.Now()
conn := blazehttp.Connect(w.addr, w.isHttps, w.timeout)
Expand Down