-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: writeHeader , serve continuation, body reading functionality
- Loading branch information
Showing
8 changed files
with
1,335 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
module myHttpServer | ||
|
||
go 1.22.1 | ||
|
||
require golang.org/x/net v0.31.0 | ||
|
||
require golang.org/x/text v0.20.0 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= | ||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= | ||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= | ||
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package internal | ||
|
||
// lower returns the ASCII lowercase version of b. | ||
func lower(b byte) byte { | ||
if 'A' <= b && b <= 'Z' { | ||
return b + ('a' - 'A') | ||
} | ||
|
||
return b | ||
} | ||
|
||
// EqualFold is strings.EqualFold, ASCII only. It reports whether s and t | ||
// are equal, ASCII-case-insensitively. | ||
func EqualFold(s, t string) bool { | ||
if len(s) != len(t) { | ||
return false | ||
} | ||
|
||
for i := 0; i < len(s); i++ { | ||
if lower(s[i]) != lower(t[i]) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package pkg | ||
|
||
import ( | ||
"net/http" | ||
|
||
"golang.org/x/net/http/httpguts" | ||
) | ||
|
||
// isProtocolSwitchHeader reports whether the request or response header | ||
// is for a protocol switch. | ||
func isProtocolSwitchHeader(h http.Header) bool { | ||
return h.Get("Upgrade") != "" && | ||
httpguts.HeaderValuesContainsToken(h["Connection"], "Upgrade") | ||
} | ||
|
||
// isProtocolSwitchResponse reports whether the response code and | ||
// response header indicate a successful protocol upgrade response. | ||
func isProtocolSwitchResponse(code int, h http.Header) bool { | ||
return code == http.StatusSwitchingProtocols && isProtocolSwitchHeader(h) | ||
} |
Oops, something went wrong.