mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
test multiple Accept header negotiation
This commit is contained in:
parent
03df4383e2
commit
4787b8203b
@ -1231,6 +1231,18 @@ func TestContextNegotiationFormatWithAccept(t *testing.T) {
|
|||||||
assert.Empty(t, c.NegotiateFormat(MIMEJSON))
|
assert.Empty(t, c.NegotiateFormat(MIMEJSON))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContextNegotiationFormatWithMultipleAccept(t *testing.T) {
|
||||||
|
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||||
|
c.Request, _ = http.NewRequest("POST", "/", nil)
|
||||||
|
c.Request.Header.Add("Accept", "text/html")
|
||||||
|
c.Request.Header.Add("Accept", "application/xhtml+xml")
|
||||||
|
c.Request.Header.Add("Accept", "application/xml;q=0.9;q=0.8")
|
||||||
|
|
||||||
|
assert.Equal(t, MIMEXML, c.NegotiateFormat(MIMEJSON, MIMEXML))
|
||||||
|
assert.Equal(t, MIMEHTML, c.NegotiateFormat(MIMEXML, MIMEHTML))
|
||||||
|
assert.Empty(t, c.NegotiateFormat(MIMEJSON))
|
||||||
|
}
|
||||||
|
|
||||||
func TestContextNegotiationFormatWithWildcardAccept(t *testing.T) {
|
func TestContextNegotiationFormatWithWildcardAccept(t *testing.T) {
|
||||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||||
c.Request, _ = http.NewRequest("POST", "/", nil)
|
c.Request, _ = http.NewRequest("POST", "/", nil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user