Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0fb2da90
Commit
0fb2da90
authored
Nov 06, 2018
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to close connection for serve-host
parent
e26f5d19
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
VERSION
test/images/serve-hostname/VERSION
+1
-1
serve_hostname.go
test/images/serve-hostname/serve_hostname.go
+11
-4
No files found.
test/images/serve-hostname/VERSION
View file @
0fb2da90
1.
1
1.
2
test/images/serve-hostname/serve_hostname.go
View file @
0fb2da90
...
...
@@ -30,10 +30,11 @@ import (
)
var
(
doTCP
=
flag
.
Bool
(
"tcp"
,
false
,
"Serve raw over TCP."
)
doUDP
=
flag
.
Bool
(
"udp"
,
false
,
"Serve raw over UDP."
)
doHTTP
=
flag
.
Bool
(
"http"
,
true
,
"Serve HTTP."
)
port
=
flag
.
Int
(
"port"
,
9376
,
"Port number."
)
doTCP
=
flag
.
Bool
(
"tcp"
,
false
,
"Serve raw over TCP."
)
doUDP
=
flag
.
Bool
(
"udp"
,
false
,
"Serve raw over UDP."
)
doHTTP
=
flag
.
Bool
(
"http"
,
true
,
"Serve HTTP."
)
doClose
=
flag
.
Bool
(
"close"
,
false
,
"Close connection per each HTTP request"
)
port
=
flag
.
Int
(
"port"
,
9376
,
"Port number."
)
)
func
main
()
{
...
...
@@ -88,6 +89,12 @@ func main() {
if
*
doHTTP
{
http
.
HandleFunc
(
"/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
log
.
Printf
(
"HTTP request from %s"
,
r
.
RemoteAddr
)
if
*
doClose
{
// Add this header to force to close the connection after serving the request.
w
.
Header
()
.
Add
(
"Connection"
,
"close"
)
}
fmt
.
Fprintf
(
w
,
"%s"
,
hostname
)
})
go
func
()
{
...
...
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