diff --git a/adaptor/README.md b/adaptor/README.md new file mode 100644 index 0000000..a0510ce --- /dev/null +++ b/adaptor/README.md @@ -0,0 +1,13 @@ +## Note: + +- When modifying the resp header in the server handler, please use `write` function to write the header. Otherwise, the modification will not take effect. + +```go +func handler(resp http.ResponseWriter, req *http.Request) { + resp.Header().Add("Content-Encoding", "test") + _, err := resp.Write([]byte("Content-Encoding: test\n")) + if err != nil { + panic(err) + } +} +``` \ No newline at end of file diff --git a/adaptor/handler_test.go b/adaptor/handler_test.go index 5c0ff89..e2e345f 100644 --- a/adaptor/handler_test.go +++ b/adaptor/handler_test.go @@ -43,7 +43,6 @@ package adaptor import ( "context" - "fmt" "io/ioutil" "net/http" "net/url" @@ -478,16 +477,10 @@ func TestFile(t *testing.T) { assert.NotEqual(t, req.Header.Get("Content-Type"), "application/x-www-form-urlencoded") err := req.ParseForm() - if err != nil { - fmt.Println(err) - panic(err) - } + assert.Nil(t, err) file, m, err := req.FormFile("file") - if err != nil { - fmt.Println(err) - panic(err) - } + assert.Nil(t, err) assert.DeepEqual(t, m.Filename, "handler.go")