mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-24 08:26:58 -04:00
HTTP/2 push support (golang 1.8) (#1215)
* WIP * HTTP2/Push for golang 1.8 * Push plugin completed for review * Correct build tag * Move push plugin position * Add build tags to tests * Gofmt that code * Add header/method validations * Load push plugin * Fixes for wrapping writers * Push after delivering file * Fixes, review changes * Remove build tags, support new syntax * Fix spelling * gofmt -s -w . * Gogland time * Add interface guards * gofmt * After review fixes
This commit is contained in:
committed by
Matt Holt
parent
579007822f
commit
cdf7cf5c3f
@@ -2,6 +2,7 @@ package httpserver
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -95,3 +96,18 @@ func (r *ResponseRecorder) CloseNotify() <-chan bool {
|
||||
}
|
||||
panic(NonCloseNotifierError{Underlying: r.ResponseWriter})
|
||||
}
|
||||
|
||||
// Push resource to client
|
||||
func (r *ResponseRecorder) Push(target string, opts *http.PushOptions) error {
|
||||
if pusher, hasPusher := r.ResponseWriter.(http.Pusher); hasPusher {
|
||||
return pusher.Push(target, opts)
|
||||
}
|
||||
|
||||
return errors.New("push is unavailable (probably chained http.ResponseWriter does not implement http.Pusher)")
|
||||
}
|
||||
|
||||
// Interface guards
|
||||
var _ http.Pusher = (*ResponseRecorder)(nil)
|
||||
var _ http.Flusher = (*ResponseRecorder)(nil)
|
||||
var _ http.CloseNotifier = (*ResponseRecorder)(nil)
|
||||
var _ http.Hijacker = (*ResponseRecorder)(nil)
|
||||
|
||||
Reference in New Issue
Block a user