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

HTTPServerResponse.writeBody overwrites previously set Content-Type header when no content type is specified #1655

Closed
dhasenan opened this Issue Jan 13, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@dhasenan

dhasenan commented Jan 13, 2017

Example:

import vibe.d;

enum bdy = `
<html>
    <body>
        <h1>Hello vibe!</h1>
    </body>
</html>
`;

shared static this()
{
    auto settings = new HTTPServerSettings;
    settings.port = 9191;
    listenHTTP(settings, (req, res) {
        res.contentType = "text/html";
        res.writeBody(bdy);
    });
}

This sends Content-Type: text/plain; charset=UTF-8.

Using res.bodyWriter.write instead resolves the problem.

@s-ludwig s-ludwig closed this in f31d351 Feb 2, 2017

s-ludwig added a commit that referenced this issue Feb 2, 2017

Only set the default content type in writeBody if none is already set.
…Fixes #1655.

This applies both, to the string based overloads and to the ubyte/stream based ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment