You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
Whenever a c.Error is called from an action, the content-type header in the response is set to text/plain; charset=utf-8. This happens on a custom error handler (where I call res.Header().Set("Content-Type", "application/json") directly) as well as the default handler.
This seems to happen regardless of the content-type set in the request. While the rendered content changes, the header does not.
I think this has to do with a res.WriteHeader call before calling res.Header().Set(), locking the headers, because no other header values can be set either. Once the res.WriteHeader call is moved after the res.Header().Set() calls, it seems to work again.
Steps to Reproduce the Problem
Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the curl command you used, that sort of thing.
Create a route
Return c.Error from that route
Expected Behavior
I'd expect to have the Content-Type header set to the request's Content-Type header, or if it's set specifically in the error handler to not be overwritten.
Actual Behavior
The response header is always set to text/plain; charset=utf-8.
Info
Please run buffalo info and paste the information below where it says "PASTE_HERE".
stefan@Stefans-MBP endpoint_manager % buffalo info
-> Go: Checking installation
✓ The `go` executable was found on your system at: /opt/homebrew/homebrew/bin/go
-> Go: Checking minimum version requirements
✓ Your version of Go, 1.14.15, meets the minimum requirements.
-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.
-> Go: Checking PATH
✓ Your PATH contains /Users/stefan/go/bin.
-> Node: Checking installation
✓ The `node` executable was found on your system at: /opt/homebrew/homebrew/bin/node
-> Node: Checking minimum version requirements
✓ Your version of Node, v15.12.0, meets the minimum requirements.
-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /usr/local/bin/npm
-> NPM: Checking minimum version requirements
✓ Your version of NPM, 7.6.0, meets the minimum requirements.
-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /usr/local/bin/yarnpkg
-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.22.10, meets the minimum requirements.
-> PostgreSQL: Checking installation
✓ The `postgres` executable was found on your system at: /opt/homebrew/homebrew/bin/postgres
-> PostgreSQL: Checking minimum version requirements
✓ Your version of PostgreSQL, 13.2.0, meets the minimum requirements.
-> MySQL: Checking installation
✘ The `mysql` executable could not be found on your system.
For help setting up your MySQL environment please follow the instructions for you platform at:
https://www.mysql.com/downloads/
-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3
-> SQLite3: Checking minimum version requirements
✓ Your version of SQLite3, 3.32.3, meets the minimum requirements.
-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:
https://www.cockroachlabs.com/docs/stable/
-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /usr/local/bin/buffalo
-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.16.23, meets the minimum requirements.
-> Buffalo: Application Details
Pwd /Users/stefan/Projects/endpoint_manager
Root /Users/stefan/Projects/endpoint_manager
GoPath /Users/stefan/go
PackagePkg endpoint_manager
ActionsPkg endpoint_manager/actions
ModelsPkg endpoint_manager/models
GriftsPkg endpoint_manager/grifts
WithModules true
Name EndpointManager
Bin bin/EndpointManager
VCS git
WithPop true
WithSQLite false
WithDep false
WithWebpack false
WithNodeJs false
WithYarn false
WithDocker true
WithGrifts true
AsWeb false
AsAPI true
InApp true
PackageJSON {map[]}
-> Buffalo: config/buffalo-app.toml
name = "EndpointManager"
bin = "bin/EndpointManager"
vcs = "git"
with_pop = true
with_sqlite = false
with_dep = false
with_webpack = false
with_nodejs = false
with_yarn = false
with_docker = true
with_grifts = true
as_web = false
as_api = true
-> Buffalo: config/buffalo-plugins.toml
[[plugin]]
binary = "buffalo-pop"
go_get = "github.com/gobuffalo/buffalo-pop/v2"
-> Buffalo: go.mod
module endpoint_manager
go 1.16
require (
github.com/MicahParks/keyfunc v0.4.0
github.com/cockroachdb/cockroach-go v2.0.1+incompatible // indirect
github.com/crowdstrike/gofalcon v0.2.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fatih/color v1.10.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/gobuffalo/buffalo v0.16.23
github.com/gobuffalo/buffalo-pop/v2 v2.3.0
github.com/gobuffalo/envy v1.9.0
github.com/gobuffalo/fizz v1.13.0 // indirect
github.com/gobuffalo/gocraft-work-adapter v0.0.0-20180714213200-7d6504f1dffe
github.com/gobuffalo/mw-contenttype v0.0.0-20190129203934-2554e742333b
github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525
github.com/gobuffalo/mw-tokenauth v1.0.0 // indirect
github.com/gobuffalo/nulls v0.4.0 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/gobuffalo/packr/v2 v2.8.0
github.com/gobuffalo/pop v4.13.1+incompatible
github.com/gobuffalo/pop/v5 v5.3.3
github.com/gobuffalo/suite v2.8.2+incompatible
github.com/gobuffalo/validate/v3 v3.3.0
github.com/gobuffalo/x v0.0.0-20190224155809-6bb134105960
github.com/gocraft/work v0.5.1 // indirect
github.com/gofrs/uuid v4.0.0+incompatible
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/hashicorp/vault/api v1.1.0
github.com/jackc/pgproto3/v2 v2.0.7 // indirect
github.com/jackc/pgx/v4 v4.11.0 // indirect
github.com/jmoiron/sqlx v1.3.3 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/lestrrat-go/jwx v1.2.0
github.com/lib/pq v1.10.1 // indirect
github.com/markbates/errx v1.1.0 // indirect
github.com/markbates/grift v1.5.0
github.com/microcosm-cc/bluemonday v1.0.9 // indirect
github.com/monoculum/formam v0.0.0-20210131081218-41b48e2a724b // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/rs/cors v1.7.0
github.com/s12v/go-jwks v0.2.1
github.com/sergi/go-diff v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/cobra v1.1.3 // indirect
github.com/square/go-jose v2.5.1+incompatible
github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
gitlab.com/eyectrl/shared/go/buffalo/buffalo_jwks_authenticator v0.2.0
gitlab.com/eyectrl/shared/go/buffalo/bugsnag v0.2.0
gitlab.com/eyectrl/shared/go/buffalo/model_validators v0.1.0
gitlab.com/eyectrl/shared/go/utils v0.0.0
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed // indirect
golang.org/x/tools v0.1.0 // indirect
)
replace (
github.com/crowdstrike/gofalcon v0.2.1 => gitlab.com/eyectrl/shared/go/gofalcon.git v0.3.0
gitlab.com/eyectrl/shared/go/buffalo/buffalo_jwks_authenticator v0.2.0 => gitlab.com/eyectrl/shared/go/buffalo/buffalo_jwks_authenticator.git v0.2.0
gitlab.com/eyectrl/shared/go/buffalo/bugsnag v0.2.0 => gitlab.com/eyectrl/shared/go/buffalo/bugsnag.git v0.2.0
gitlab.com/eyectrl/shared/go/buffalo/model_validators v0.1.0 => gitlab.com/eyectrl/shared/go/buffalo/model_validators.git v0.1.0
gitlab.com/eyectrl/shared/go/utils v0.0.0 => gitlab.com/eyectrl/shared/go/utils.git v0.0.0
)
The text was updated successfully, but these errors were encountered:
Description
Whenever a
c.Error
is called from an action, the content-type header in the response is set totext/plain; charset=utf-8
. This happens on a custom error handler (where I callres.Header().Set("Content-Type", "application/json")
directly) as well as the default handler.This seems to happen regardless of the content-type set in the request. While the rendered content changes, the header does not.
I think this has to do with a
res.WriteHeader
call before callingres.Header().Set()
, locking the headers, because no other header values can be set either. Once theres.WriteHeader
call is moved after theres.Header().Set()
calls, it seems to work again.Steps to Reproduce the Problem
Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the
curl
command you used, that sort of thing.c.Error
from that routeExpected Behavior
I'd expect to have the
Content-Type
header set to the request'sContent-Type
header, or if it's set specifically in the error handler to not be overwritten.Actual Behavior
The response header is always set to
text/plain; charset=utf-8
.Info
Please run
buffalo info
and paste the information below where it says "PASTE_HERE".The text was updated successfully, but these errors were encountered: