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

     1  // Copyright 2016 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  //go:generate bundle -o=h2_bundle.go -prefix=http2 -tags=!nethttpomithttp2 golang.org/x/net/http2
     6  
     7  package http
     8  
     9  import (
    10  	"github.com/shogo82148/std/io"
    11  )
    12  
    13  // NoBodyはバイトを持たない [io.ReadCloser] です。Readは常にEOFを返し、
    14  // Closeは常にnilを返します。これは、リクエストがゼロバイトであることを
    15  // 明示的に示すために、送信元クライアントのリクエストで使用することができます。
    16  // ただし、代わりに [Request.Body] をnilに設定することもできます。
    17  var NoBody = noBody{}
    18  
    19  var (
    20  	// NoBodyからのio.Copyがバッファを必要としないことを検証する
    21  	_ io.WriterTo   = NoBody
    22  	_ io.ReadCloser = NoBody
    23  )
    24  
    25  // PushOptionsは、[Pusher.Push] のオプションを記述します。
    26  type PushOptions struct {
    27  
    28  	// Methodは要求されたリクエストのHTTPメソッドを指定します。
    29  	// 設定する場合、"GET"または"HEAD"でなければなりません。空は"GET"を意味します。
    30  	Method string
    31  
    32  	// Headerは追加の約束されたリクエストヘッダーを指定します。これには":path"や":scheme"などのHTTP/2疑似ヘッダーフィールドは含めることができませんが、これらは自動的に追加されます。
    33  	Header Header
    34  }
    35  
    36  // Pusherは、HTTP/2サーバープッシュをサポートするResponseWritersによって実装されるインターフェースです。
    37  // 詳細については、 https://tools.ietf.org/html/rfc7540#section-8.2 を参照してください。
    38  type Pusher interface {
    39  	Push(target string, opts *PushOptions) error
    40  }