Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
caddy
Commits
f58653bc
Commit
f58653bc
authored
May 02, 2017
by
Tw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal: inherit original ResponseWriter's interfaces
Signed-off-by:
Tw
<
tw19881113@gmail.com
>
parent
e0ed7093
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
caddyhttp/internalsrv/internal.go
caddyhttp/internalsrv/internal.go
+50
-0
No files found.
caddyhttp/internalsrv/internal.go
View file @
f58653bc
...
...
@@ -7,6 +7,8 @@
package
internalsrv
import
(
"bufio"
"net"
"net/http"
"github.com/mholt/caddy/caddyhttp/httpserver"
...
...
@@ -94,3 +96,51 @@ func (w internalResponseWriter) Write(b []byte) (int, error) {
}
return
w
.
ResponseWriter
.
Write
(
b
)
}
// Hijack implements http.Hijacker. It simply wraps the underlying
// ResponseWriter's Hijack method if there is one, or returns an error.
func
(
w
internalResponseWriter
)
Hijack
()
(
net
.
Conn
,
*
bufio
.
ReadWriter
,
error
)
{
if
hj
,
ok
:=
w
.
ResponseWriter
.
(
http
.
Hijacker
);
ok
{
return
hj
.
Hijack
()
}
return
nil
,
nil
,
httpserver
.
NonHijackerError
{
Underlying
:
w
.
ResponseWriter
}
}
// Flush implements http.Flusher. It simply wraps the underlying
// ResponseWriter's Flush method if there is one, or panics.
func
(
w
internalResponseWriter
)
Flush
()
{
if
f
,
ok
:=
w
.
ResponseWriter
.
(
http
.
Flusher
);
ok
{
f
.
Flush
()
}
else
{
panic
(
httpserver
.
NonFlusherError
{
Underlying
:
w
.
ResponseWriter
})
}
}
// CloseNotify implements http.CloseNotifier.
// It just inherits the underlying ResponseWriter's CloseNotify method.
// It panics if the underlying ResponseWriter is not a CloseNotifier.
func
(
w
internalResponseWriter
)
CloseNotify
()
<-
chan
bool
{
if
cn
,
ok
:=
w
.
ResponseWriter
.
(
http
.
CloseNotifier
);
ok
{
return
cn
.
CloseNotify
()
}
panic
(
httpserver
.
NonCloseNotifierError
{
Underlying
:
w
.
ResponseWriter
})
}
// Push implements http.Pusher.
// It just inherits the underlying ResponseWriter's Push method.
// It panics if the underlying ResponseWriter is not a Pusher.
func
(
w
internalResponseWriter
)
Push
(
target
string
,
opts
*
http
.
PushOptions
)
error
{
if
pusher
,
hasPusher
:=
w
.
ResponseWriter
.
(
http
.
Pusher
);
hasPusher
{
return
pusher
.
Push
(
target
,
opts
)
}
return
httpserver
.
NonPusherError
{
Underlying
:
w
.
ResponseWriter
}
}
// Interface guards
var
(
_
http
.
Pusher
=
internalResponseWriter
{}
_
http
.
Flusher
=
internalResponseWriter
{}
_
http
.
CloseNotifier
=
internalResponseWriter
{}
_
http
.
Hijacker
=
internalResponseWriter
{}
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment