Error with 400 Bad Request
when both 'file' and 'shorten' set
#65
@ -159,3 +159,26 @@ func TestIssue60(t *testing.T) {
|
||||
srv.ServeHTTP(rr, req)
|
||||
checkStatusCode(t, rr, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func TestIssue56(t *testing.T) {
|
||||
srv, _ := createTemporaryRouter(t)
|
||||
|
||||
// Make a POST request with both a 'file' *and* a 'shorten' part.
|
||||
var body bytes.Buffer
|
||||
form := multipart.NewWriter(&body)
|
||||
if _, err := form.CreateFormFile("file", "empty.txt"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := form.CreateFormField("shorten"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
form.Close()
|
||||
req, err := http.NewRequest("POST", "/", bytes.NewReader(body.Bytes()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Header.Add("Content-Type", form.FormDataContentType())
|
||||
rr := httptest.NewRecorder()
|
||||
srv.ServeHTTP(rr, req)
|
||||
checkStatusCode(t, rr, http.StatusBadRequest)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user