BUG: lambdaurl.Wrap still does not add Content-Length headers?
- 主要言語
- Go
- スター
- 3.8k
- フォーク
- 578
- 平均マージ
- 8時間 18分
- マージ済み PR(30日)
- 1
説明
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
Following https://github.com/aws/aws-lambda-go/issues/508,
> The [`http.ResponseWriter`](https://pkg.go.dev/net/http#ResponseWriter) implementation says the following thing about Content-Type header (and it actually has a note about Content-Length too).
>
> > If WriteHeader has not yet been called, Write calls
> > WriteHeader(http.StatusOK) before writing the data. If the Header
> > does not contain a Content-Type line, Write adds a Content-Type set
> > to the result of passing the initial 512 bytes of written data to
> > DetectContentType. Additionally, if the total size of all written
> > data is under a few KB and there are no Flush calls, the
> > Content-Length header is added automatically.
>
> As of right now the `lambdaurl.Wrap` implementation completely misses this . . .
which get closed as a part of https://github.com/aws/aws-lambda-go/releases/tag/v1.42.0
However a quick search of `Content-Length` in the change log of
https://github.com/aws/aws-lambda-go/compare/v1.41.0...v1.42.0
did not get any hits:
> 
Are the Content-Length headers being added now?
**Describe the solution you'd like**
Add the Content-Length headers, _properly_.
**Additional context**
For a handler like:
```go
mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
_, _ = w.Write([]byte("Hello World!"))
})
```
I was able to get return from it if I try it locally, However, if using lambdaurl, I got empty returns, i.e., **`Content-Length: 0`**.
Please double-check. Thanks
コントリビューションガイド
調査の方向性
lambdaurl.Wrap の実装から始め、ResponseWriter の動作を、issue に記載されている net/http の動作と比較します。提供されている /hello handler を lambdaurl 経由でローカルに再現し、小さなレスポンスが Content-Length: 0 ではなく、期待される Content-Length と body を返すことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- aws, go
- 領域
- api, backend, cloud
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100