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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Type should be optional for all 3xx redirects #484

Merged
merged 1 commit into from
Jun 26, 2020

Conversation

f-w
Copy link
Contributor

@f-w f-w commented Jun 7, 2020

When response is a redirect (302 by default), for example await options.httpContext.res.redirect(redirectUrl) generates following error

(node:8972) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:541:11)
    at ServerResponse.header (C:\Users\x\myProject\node_modules\express\lib\response.js:771:10)
    at HttpContext.done (C:\Users\x\myProject\node_modules\strong-remoting\lib\http-context.js:574:9)
    ...

This PR makes Content-Type header optional since message body is optional for redirects.

Checklist

馃憠 Read and sign the CLA (Contributor License Agreement) 馃憟

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • Commit messages are following our guidelines

@slnode
Copy link

slnode commented Jun 7, 2020

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @f-w for the pull request. Let's start by adding a test to reproduce the problem, verify the fix, and prevent regressions in the future.

@bajtos
Copy link
Member

bajtos commented Jun 8, 2020

We will also need you to sign our Contributor License Agreement before we can accept your patch, see https://cla.strongloop.com/agreements/strongloop/strong-remoting

@f-w
Copy link
Contributor Author

f-w commented Jun 8, 2020

@bajtos, I have added test case, verified it failed before and works after.
Also signed license agreement.

@dhmlau
Copy link
Member

dhmlau commented Jun 11, 2020

@slnode test please

@dhmlau
Copy link
Member

dhmlau commented Jun 11, 2020

@f-w, for CLA, the author (meaning GitHub id) of all the commits needs to sign the CLA. It seems like you used two account to do the commits?

Please also fix the commit linter error:

**************************************************
**
**  Linting commit logs
**
**  1 problems found:
**    a8a58cd - Content-Type should be optional for all 3xx redirec: First line should be 50 characters or less (saw 53)
**
**************************************************

Reference:

@dhmlau dhmlau added the community-contribution Patches contributed by community label Jun 11, 2020
@f-w
Copy link
Contributor Author

f-w commented Jun 11, 2020

@dhmlau I have addressed both CLA and commit msg length issue.

@dhmlau
Copy link
Member

dhmlau commented Jun 16, 2020

@slnode test please

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @f-w for adding a test, the changes LGTM now 馃憦

@bajtos bajtos merged commit bb02764 into strongloop:master Jun 26, 2020
@bajtos
Copy link
Member

bajtos commented Jun 26, 2020

Published in [email protected] 馃帀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Patches contributed by community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants