GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(bind): match request media type case-insensitively in BindBody by yxshee · Pull Request #3213 · labstack/echo

Conversation

@yxshee

@yxshee yxshee commented Nov 8, 2026

Copy link
Copy Markdown

BindBody compares the request media type against the lowercase MIME constants as-is, so a client that sends a supported type in a different case gets a 415. Media type and subtype names are case-insensitive (RFC 9110 section 8.3.1).

e.POST("/", func(c *echo.Context) error {
	var v struct{ ID int `json:"id"` }
	return c.Bind(&v)
})
// POST / with Content-Type: Application/JSON and body {"id": 1}
// got: 415 Unsupported Media Type, expected: bound with ID=1

The same happens for Application/XML, Text/XML, Application/X-WWW-Form-Urlencoded and Multipart/Form-Data.

The fix lowercases the media type before the switch. Parameters are left untouched, and the form and multipart branches already go through net/http, which parses the type with mime.ParseMediaType. #3095 had the same change and was labelled bug/v5 before its author closed it.

TestDefaultBinder_BindBody_MediaTypeIsCaseInsensitive covers all five types. On master every case fails with code=415, message=Unsupported Media Type. With the fix, go test -race ./..., go vet, staticcheck and golint all pass.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yxshee
fix(bind): match request media type case-insensitively in BindBody
e4f7d7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@yxshee
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.