summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/fastcgi/client_test.go
diff options
context:
space:
mode:
authorWeidiDeng <weidi_deng@icloud.com>2022-09-03 06:57:55 +0800
committerGitHub <noreply@github.com>2022-09-02 16:57:55 -0600
commit83b26975bd9330c4cfc44d52b106da739240e72b (patch)
tree23cd0c242cd5a42f8f916bbb29fcfa380006352a /modules/caddyhttp/reverseproxy/fastcgi/client_test.go
parent005c5a63823b19382aa918f1e1f3288e66446225 (diff)
fastcgi: Optimize FastCGI transport (#4978)
* break up code and use lazy reading and pool bufio.Writer * close underlying connection when operation failed * allocate bufWriter and streamWriter only once * refactor record writing * rebase from master * handle err * Fix type assertion Also reduce some duplication * Refactor client and clientCloser for logging Should reduce allocations * Minor cosmetic adjustments; apply Apache license * Appease the linter Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp/reverseproxy/fastcgi/client_test.go')
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/client_test.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/client_test.go b/modules/caddyhttp/reverseproxy/fastcgi/client_test.go
index ef3474d..78e5713 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/client_test.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/client_test.go
@@ -118,12 +118,14 @@ func (s FastCGIServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
}
func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[string]string, files map[string]string) (content []byte) {
- fcgi, err := Dial("tcp", ipPort)
+ conn, err := net.Dial("tcp", ipPort)
if err != nil {
log.Println("err:", err)
return
}
+ fcgi := client{rwc: conn, reqID: 1}
+
length := 0
var resp *http.Response
@@ -168,7 +170,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
content, _ = io.ReadAll(resp.Body)
log.Println("c: send data length ≈", length, string(content))
- fcgi.Close()
+ conn.Close()
time.Sleep(1 * time.Second)
if bytes.Contains(content, []byte("FAILED")) {