Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed May 17, 2024
1 parent 56253e5 commit 6b6a117
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ func TestEchoMetaRequestValidator(t *testing.T) {
c, b := request(POST, "/root/post", e, func(r *http.Request) {
r.Form = url.Values{}
r.Form.Add(`Name`, `OK`)
r.Header.Set("Content-Type", echo.MIMEMultipartForm)
r.Header.Set("Content-Type", echo.MIMEApplicationForm)
r.Body = io.NopCloser(bytes.NewReader([]byte(r.Form.Encode())))
})
assert.Equal(t, http.StatusOK, c)
assert.Equal(t, `OK`, b)

c, b = request(POST, "/root/post", e, func(r *http.Request) {
r.Form = url.Values{}
r.Header.Set("Content-Type", echo.MIMEMultipartForm)
r.Header.Set("Content-Type", echo.MIMEApplicationForm)
r.Body = io.NopCloser(bytes.NewReader([]byte(r.Form.Encode())))
})
assert.Equal(t, http.StatusInternalServerError, c)
Expand Down Expand Up @@ -156,15 +156,15 @@ func TestEchoMetaRequestValidator2(t *testing.T) {
c, b := request(POST, "/root/post2", e, func(r *http.Request) {
r.Form = url.Values{}
r.Form.Add(`Name`, `OK`)
r.Header.Set("Content-Type", echo.MIMEMultipartForm)
r.Header.Set("Content-Type", echo.MIMEApplicationForm)
r.Body = io.NopCloser(bytes.NewReader([]byte(r.Form.Encode())))
})
assert.Equal(t, http.StatusOK, c)
assert.Equal(t, `OK`, b)

c, b = request(POST, "/root/post2", e, func(r *http.Request) {
r.Form = url.Values{}
r.Header.Set("Content-Type", echo.MIMEMultipartForm)
r.Header.Set("Content-Type", echo.MIMEApplicationForm)
r.Body = io.NopCloser(bytes.NewReader([]byte(r.Form.Encode())))
})
assert.Equal(t, http.StatusInternalServerError, c)
Expand Down Expand Up @@ -192,15 +192,15 @@ func TestEchoMetaRequestValidator3(t *testing.T) {
c, b := request(POST, "/root/post3", e, func(r *http.Request) {
r.Form = url.Values{}
r.Form.Add(`Name`, `OK`)
r.Header.Set("Content-Type", echo.MIMEMultipartForm)
r.Header.Set("Content-Type", echo.MIMEApplicationForm)
r.Body = io.NopCloser(bytes.NewReader([]byte(r.Form.Encode())))
})
assert.Equal(t, http.StatusOK, c)
assert.Equal(t, `OK`, b)

c, b = request(POST, "/root/post3", e, func(r *http.Request) {
r.Form = url.Values{}
r.Header.Set("Content-Type", echo.MIMEMultipartForm)
r.Header.Set("Content-Type", echo.MIMEApplicationForm)
r.Body = io.NopCloser(bytes.NewReader([]byte(r.Form.Encode())))
})
assert.Equal(t, http.StatusInternalServerError, c)
Expand Down
3 changes: 2 additions & 1 deletion variable_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package echo
import (
stdJSON "encoding/json"
"encoding/xml"
"errors"
"fmt"
"net/http"
"strings"
Expand Down Expand Up @@ -109,7 +110,7 @@ var (
},
MIMEMultipartForm: func(i interface{}, ctx Context, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error {
_, err := ctx.Request().MultipartForm()
if err != nil {
if err != nil && !errors.Is(err, http.ErrMissingBoundary) {
return err
}
return FormToStructWithDecoder(ctx.Echo(), i, ctx.Request().Form().All(), ``, valueDecoders, filter...)
Expand Down

0 comments on commit 6b6a117

Please sign in to comment.