Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Error after 302 then 304 #7051

Closed
Hamdy opened this issue Feb 5, 2014 · 4 comments
Closed

Error after 302 then 304 #7051

Hamdy opened this issue Feb 5, 2014 · 4 comments
Labels

Comments

@Hamdy
Copy link

Hamdy commented Feb 5, 2014

Hello,
am having an http action that redirects user to another action when user has met some condition.
the problem is I get frequently get garbage HTML in my browser page like:

    </div>
    </div>
</div>
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
        ..........
    </body>
</html>HTTP/1.1 304 Not Modified
ETag: "-485306310"
Date: Wed, 05 Feb 2014 17:32:56 GMT
Connection: keep-alive

This case sometimes happens for me when there's 302 then 304 HTTP responses.

debug: discarding transport
Passport: DeSerialzing User from session 52f254ffa33d553431b2faf6
GET / 302 31ms - 66b
Passport: DeSerialzing User from session 52f254ffa33d553431b2faf6
GET /go 304 27ms

Then I get that garbage HTML in my browser

@indutny
Copy link
Member

indutny commented Feb 5, 2014

Hello! May I ask you to provide a test case for us?

@trevnorris trevnorris added the http label Feb 5, 2014
@Hamdy
Copy link
Author

Hamdy commented Feb 6, 2014

Hello, I don't have a test case for this,
but my use case was the following:

# home ('/')
exports.home = function(req, res){
     if(user is logged in)
            redirect('/chat')
}

 # chat ('/chat')
exports.chat = function(req, res){
     if(user not logged in)
            redirect('/')
      else
          // every thing is fine
}

Now The error used to happen more often when connection is slow a bit, and I'm logged in
and my location is "/chat" then trying to go to "/", this error happens
as / will redirect me back to /chat.

We replaced redirect('/chat') with

   res.writeHead(302, { 'Location': '/chat'});
    res.end();

This seems to help in solving the problem, as we can't reproduce it again.

@indutny
Copy link
Member

indutny commented Feb 14, 2014

Sorry, could you please provide a complete test case that won't require me to finish it in order to be able to test it?

@jasnell
Copy link
Member

jasnell commented May 28, 2015

Closing. @Hamdy if this is still an issue, please provide a complete test case as @indutny asked and we can reopen if necessary.

@jasnell jasnell closed this as completed May 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants