Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Go Httpbin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Nix
Go Httpbin
Commits
c49dd449
Commit
c49dd449
authored
8 years ago
by
Will McCutchen
Browse files
Options
Downloads
Patches
Plain Diff
Use generic notImplementedHandler for /digest-auth
parent
729c7706
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
httpbin/handlers.go
+4
-12
4 additions, 12 deletions
httpbin/handlers.go
httpbin/handlers_test.go
+4
-4
4 additions, 4 deletions
httpbin/handlers_test.go
httpbin/httpbin.go
+3
-1
3 additions, 1 deletion
httpbin/httpbin.go
with
11 additions
and
17 deletions
httpbin/handlers.go
+
4
−
12
View file @
c49dd449
...
@@ -21,6 +21,10 @@ var acceptedMediaTypes = []string{
...
@@ -21,6 +21,10 @@ var acceptedMediaTypes = []string{
"image/"
,
"image/"
,
}
}
func
notImplementedHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
Error
(
w
,
"Not implemented"
,
http
.
StatusNotImplemented
)
}
// Index renders an HTML index page
// Index renders an HTML index page
func
(
h
*
HTTPBin
)
Index
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
(
h
*
HTTPBin
)
Index
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
r
.
URL
.
Path
!=
"/"
{
if
r
.
URL
.
Path
!=
"/"
{
...
@@ -383,18 +387,6 @@ func (h *HTTPBin) HiddenBasicAuth(w http.ResponseWriter, r *http.Request) {
...
@@ -383,18 +387,6 @@ func (h *HTTPBin) HiddenBasicAuth(w http.ResponseWriter, r *http.Request) {
writeJSON
(
w
,
body
,
http
.
StatusOK
)
writeJSON
(
w
,
body
,
http
.
StatusOK
)
}
}
// DigestAuth is not yet implemented, and returns 501 Not Implemented. It
// appears that stdlib support for working with digest authentication is
// lacking, and I'm not yet ready to implement it myself.
func
(
h
*
HTTPBin
)
DigestAuth
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
parts
:=
strings
.
Split
(
r
.
URL
.
Path
,
"/"
)
if
len
(
parts
)
!=
5
{
http
.
Error
(
w
,
"Not Found"
,
http
.
StatusNotFound
)
return
}
http
.
Error
(
w
,
"Not Implemented"
,
http
.
StatusNotImplemented
)
}
// Stream responds with max(n, 100) lines of JSON-encoded request data.
// Stream responds with max(n, 100) lines of JSON-encoded request data.
func
(
h
*
HTTPBin
)
Stream
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
(
h
*
HTTPBin
)
Stream
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
parts
:=
strings
.
Split
(
r
.
URL
.
Path
,
"/"
)
parts
:=
strings
.
Split
(
r
.
URL
.
Path
,
"/"
)
...
...
This diff is collapsed.
Click to expand it.
httpbin/handlers_test.go
+
4
−
4
View file @
c49dd449
...
@@ -1075,11 +1075,11 @@ func TestDigestAuth(t *testing.T) {
...
@@ -1075,11 +1075,11 @@ func TestDigestAuth(t *testing.T) {
url
string
url
string
status
int
status
int
}{
}{
{
"/digest-auth/qop/user/pass"
,
http
.
StatusNotImplemented
},
{
"/digest-auth"
,
http
.
StatusNotFound
},
{
"/digest-auth"
,
http
.
StatusNotFound
},
{
"/digest-auth/user"
,
http
.
StatusNotFound
},
{
"/digest-auth/qop/user/pass"
,
http
.
StatusNotImplemented
},
{
"/digest-auth/user/pass"
,
http
.
StatusNotFound
},
{
"/digest-auth/user"
,
http
.
StatusNotImplemented
},
{
"/digest-auth/qop/user/pass/foo"
,
http
.
StatusNotFound
},
{
"/digest-auth/user/pass"
,
http
.
StatusNotImplemented
},
{
"/digest-auth/qop/user/pass/foo"
,
http
.
StatusNotImplemented
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
t
.
Run
(
"ok"
+
test
.
url
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"ok"
+
test
.
url
,
func
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
httpbin/httpbin.go
+
3
−
1
View file @
c49dd449
...
@@ -112,7 +112,6 @@ func (h *HTTPBin) Handler() http.Handler {
...
@@ -112,7 +112,6 @@ func (h *HTTPBin) Handler() http.Handler {
mux
.
HandleFunc
(
"/basic-auth/"
,
h
.
BasicAuth
)
mux
.
HandleFunc
(
"/basic-auth/"
,
h
.
BasicAuth
)
mux
.
HandleFunc
(
"/hidden-basic-auth/"
,
h
.
HiddenBasicAuth
)
mux
.
HandleFunc
(
"/hidden-basic-auth/"
,
h
.
HiddenBasicAuth
)
mux
.
HandleFunc
(
"/digest-auth/"
,
h
.
DigestAuth
)
mux
.
HandleFunc
(
"/deflate"
,
h
.
Deflate
)
mux
.
HandleFunc
(
"/deflate"
,
h
.
Deflate
)
mux
.
HandleFunc
(
"/gzip"
,
h
.
Gzip
)
mux
.
HandleFunc
(
"/gzip"
,
h
.
Gzip
)
...
@@ -139,6 +138,9 @@ func (h *HTTPBin) Handler() http.Handler {
...
@@ -139,6 +138,9 @@ func (h *HTTPBin) Handler() http.Handler {
mux
.
HandleFunc
(
"/image/"
,
h
.
Image
)
mux
.
HandleFunc
(
"/image/"
,
h
.
Image
)
mux
.
HandleFunc
(
"/xml"
,
h
.
XML
)
mux
.
HandleFunc
(
"/xml"
,
h
.
XML
)
// Not implemented
mux
.
HandleFunc
(
"/digest-auth/"
,
notImplementedHandler
)
// Make sure our ServeMux doesn't "helpfully" redirect these invalid
// Make sure our ServeMux doesn't "helpfully" redirect these invalid
// endpoints by adding a trailing slash. See the ServeMux docs for more
// endpoints by adding a trailing slash. See the ServeMux docs for more
// info: https://golang.org/pkg/net/http/#ServeMux
// info: https://golang.org/pkg/net/http/#ServeMux
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment