github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/net/http/httputil/httputil.go (about)

     1  // Copyright 2014 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package httputilは、net/httpパッケージにある一般的なものと補完するHTTPユーティリティ関数を提供します。
     6  package httputil
     7  
     8  import (
     9  	"github.com/shogo82148/std/io"
    10  	"github.com/shogo82148/std/net/http/internal"
    11  )
    12  
    13  // NewChunkedReaderは、rから読み込まれたデータをHTTPの「チャンク」形式から変換して返す新しいchunkedReaderを返します。
    14  // chunkedReaderは、最後の長さ0のチャンクが読み込まれた時に [io.EOF] を返します。
    15  //
    16  // NewChunkedReaderは通常のアプリケーションでは必要ありません。httpパッケージは、応答ボディを読み込む際に自動的にチャンクをデコードします。
    17  func NewChunkedReader(r io.Reader) io.Reader
    18  
    19  // NewChunkedWriter は、w に書き込む前に書き込みを HTTP の "chunked" フォーマットに変換する新しい chunkedWriter を返します。返された chunkedWriter を閉じると、ストリームの終わりを示す最後の長さが 0 のチャンクが送信されますが、トレーラーの後に表示される最後の CRLF は送信されません。トレーラーと最後の CRLF は別個に書き込む必要があります。
    20  // NewChunkedWriter は通常のアプリケーションでは必要ありません。http パッケージは、ハンドラが Content-Length ヘッダーを設定しない場合、自動的にチャンキングを追加します。ハンドラ内で NewChunkedWriter を使用すると、二重チャンキングや Content-Length 長さでのチャンキングなど、間違った結果になります。
    21  func NewChunkedWriter(w io.Writer) io.WriteCloser
    22  
    23  // ErrLineTooLong は、行が長すぎる不正なチャンクデータを読み取ると返されます。
    24  var ErrLineTooLong = internal.ErrLineTooLong