Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong encoding if use Controllers #41

Open
bosom opened this issue Jul 30, 2013 · 5 comments
Open

Wrong encoding if use Controllers #41

bosom opened this issue Jul 30, 2013 · 5 comments

Comments

@bosom
Copy link

bosom commented Jul 30, 2013

If use Controllers and set custom encoding, encoding don't work
Example:

goweb.MapBefore(func(c context.Context) error {
   // add a custom header
   c.HttpResponseWriter().Header().Set(`Content-Type`, `application/json; charset=UTF-8`)
   return nil
})

Bugfix this:
File: goweb/responders/goweb_api_responders.go

@@ -118,7 +118,9 @@ func (a *GowebAPIResponder) WriteResponseObject(ctx context.Context, status int
@matryer
Copy link
Member

matryer commented Jul 30, 2013

Are you saying the header isn't properly set?

@tylerstillwater
Copy link
Contributor

Sounds to me like codecs is overwriting it when doing the encoding.

On Jul 30, 2013, at 9:29 AM, Mat Ryer [email protected] wrote:

Are you saying the header isn't properly set?


Reply to this email directly or view it on GitHub.

@matryer
Copy link
Member

matryer commented Jul 30, 2013

That sounds right - that's an interesting one. We'll look at how we might solve this.

@bosom
Copy link
Author

bosom commented Jul 30, 2013

Temporarily made ​​a patch:
from

    // use the HTTP responder to respond
    ctx.HttpResponseWriter().Header().Set("Content-Type", codec.ContentType()) // TODO: test me

to

    // use the HTTP responder to respond
    if ctx.HttpResponseWriter().Header().Get("Content-Type") == "" {
        ctx.HttpResponseWriter().Header().Set("Content-Type", codec.ContentType()) // TODO: test me
    }

@matryer
Copy link
Member

matryer commented Aug 19, 2013

What do we think about this as a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants