Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Error after 302 then 304 #7051

Open
Hamdy opened this Issue · 3 comments

3 participants

@Hamdy

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
Owner

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

@trevnorris trevnorris added the http label
@Hamdy

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
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.