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

CI: Server cannot append header after HTTP headers have been sent #112

Closed
Scippy opened this issue Mar 22, 2018 · 2 comments
Closed

CI: Server cannot append header after HTTP headers have been sent #112

Scippy opened this issue Mar 22, 2018 · 2 comments
Assignees
Milestone

Comments

@Scippy
Copy link

Scippy commented Mar 22, 2018

Looking at event log I could see a lot of these exceptions: Server cannot append header after HTTP headers have been sent
Looking at them I've also noticed that one of the cases in which they are fired is when I go from Cart page on Checkout page after clicking on 'Secure Checkout' button.
Searching on Google I've found a lot of post about this MVC exception (this one of them) and it seems to be caused by use of:
Response.Redirect
instead
return Redirect
in fact, looking at HCC source code, in the CartController.cs when the 'Secure Checkout' button is pressed is called the ActionResult IndexPost() where is called the void ForwardToCheckout with in turn a call to Checkout controller using just Response.Redirect
I did a quick test modifing the ActionResult IndexPost() in CartController in this way:
`// POST: /Cart/
[ActionName("Index")]
[HccHttpPost]
public ActionResult IndexPost()
{
var model = IndexSetup();
LoadCart(model);

        var intResult = CartIntegration.Create(HccApp).BeforeProceedToCheckout(HccApp, model);

        if (!intResult.IsAborted)
        {
            if (CheckForStockOnItems(model))
            {
                return Redirect(Url.RouteHccUrl(HccRoute.Checkout, null, Uri.UriSchemeHttps));
                //ForwardToCheckout(model);
            }
        }
        else
        {
            FlashWarning(intResult.AbortMessage);
        }

        return View(model);
    }

`
In this quick test I bypass the ForwardToCheckout call replacing directly with a 'return Redirect' to Checkout, and this remove all exceptions around 'Secure Checkout' button.
Then I am therefore reasonably sure that the part of the source code to be corrected is that part.
I do not know if the Response.Redirect was also used in other parts of the HCC project, in that case it is to be reviewed in all the points where it was used.
Here you can find the reference to discussion about this on hotcakes.org forum:
https://hotcakes.org/Forums/g/posts/t/163/find/unread/Exceptions-in-event-log

@WillStrohl WillStrohl changed the title Server cannot append header after HTTP headers have been sent CI: Server cannot append header after HTTP headers have been sent Mar 22, 2018
@WillStrohl
Copy link
Member

Great stuff, @Scippy ! We'll look into incorporating this into the next release. I'm adding it to that milestone for now.

@WillStrohl WillStrohl added this to the 03.02.02 milestone Oct 22, 2018
@WillStrohl WillStrohl self-assigned this Jun 1, 2019
WillStrohl pushed a commit that referenced this issue Jun 1, 2019
PR #112 : CI: Server cannot append header after HTTP headers have been sent
@WillStrohl
Copy link
Member

This has been confirmed to be resolved in the pending 03.02.02 release, but only during checkout. There is another instance that may occur, but it hasn't yet been determined when/how.

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

No branches or pull requests

2 participants