Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add adaptor README #8

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions adaptor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Tips:

- 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)
}
}
```
11 changes: 2 additions & 9 deletions adaptor/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ package adaptor

import (
"context"
"fmt"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -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")

Expand Down
Loading