@@ -100,3 +100,42 @@ var (
100
100
_ io.WriterTo = NoBody
101
101
_ io.ReadCloser = NoBody
102
102
)
103
+
104
+ // PushOptions describes options for Pusher.Push.
105
+ type PushOptions struct {
106
+ // Method specifies the HTTP method for the promised request.
107
+ // If set, it must be "GET" or "HEAD". Empty means "GET".
108
+ Method string
109
+
110
+ // Header specifies additional promised request headers. This cannot
111
+ // include HTTP/2 pseudo header fields like ":path" and ":scheme",
112
+ // which will be added automatically.
113
+ Header Header
114
+ }
115
+
116
+ // Pusher is the interface implemented by ResponseWriters that support
117
+ // HTTP/2 server push. For more background, see
118
+ // https://tools.ietf.org/html/rfc7540#section-8.2.
119
+ type Pusher interface {
120
+ // Push initiates an HTTP/2 server push. This constructs a synthetic
121
+ // request using the given target and options, serializes that request
122
+ // into a PUSH_PROMISE frame, then dispatches that request using the
123
+ // server's request handler. If opts is nil, default options are used.
124
+ //
125
+ // The target must either be an absolute path (like "/path") or an absolute
126
+ // URL that contains a valid host and the same scheme as the parent request.
127
+ // If the target is a path, it will inherit the scheme and host of the
128
+ // parent request.
129
+ //
130
+ // The HTTP/2 spec disallows recursive pushes and cross-authority pushes.
131
+ // Push may or may not detect these invalid pushes; however, invalid
132
+ // pushes will be detected and canceled by conforming clients.
133
+ //
134
+ // Handlers that wish to push URL X should call Push before sending any
135
+ // data that may trigger a request for URL X. This avoids a race where the
136
+ // client issues requests for X before receiving the PUSH_PROMISE for X.
137
+ //
138
+ // Push returns ErrNotSupported if the client has disabled push or if push
139
+ // is not supported on the underlying connection.
140
+ Push (target string , opts * PushOptions ) error
141
+ }
0 commit comments