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

using localhost as test server locally fails #27

Open
AndreasMadsen opened this issue Jan 11, 2013 · 2 comments
Open

using localhost as test server locally fails #27

AndreasMadsen opened this issue Jan 11, 2013 · 2 comments

Comments

@AndreasMadsen
Copy link

I reproduces this on a mac, where I updated browser-launcher to 0.2.0

To reproduce run this testing file with testling example/localhost.js --browser=chrome.

var test = require('../');

test('title test', function (t) {
    var w = t.createWindow('http://localhost:17000/', { t : t });
    w.next(function (win, $) {
        t.equal(win.location.href, 'http://localhost:17000/');
        t.equal(win.document.title, 'Localhost Test');
        t.end();
    });
});

The localhost server looks like this:

var http = require('http');
var path = require('path');
var filed = require('filed');

var server = http.createServer(function (req, res) {
    req.pipe(filed( path.resolve(__dirname, 'index.html') )).pipe(res);
});

server.listen(17000, '127.0.0.1', function () {
    console.log('ready on 127.0.0.1:17000');
});
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Localhost Test</title>
    </head>
    <body>
        Hallo World
    </body>
</html>

It should be noted that testling example/window.js --browser=chrome works perfectly!

@jesseditson
Copy link

I'm running in to this issue as well, here's some more details:

when requesting a local site via a browser, here's the headers I get:

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 47678
ETag: "-494042136"
Set-Cookie: connect.sid=<snip>; Path=/; HttpOnly
Date: Sun, 03 Mar 2013 01:27:37 GMT
Connection: keep-alive

However, when requesting through the proxy, I get these headers:

HTTP/1.1 200 OK
x-powered-by: Express
content-type: text/html; charset=utf-8
content-length: 1665155
date: Sun, 03 Mar 2013 01:23:46 GMT
connection: close

So, a few things are different, the cookie and ETag shouldn't matter, but the content-length is definitely wrong, and the proxy is sending "close" instead of "keep-alive" (not sure if that's an issue, but could be related to the incorrect content length).

I think the issue probably exists in proxy.js, not sure why it would act differently locally as opposed to when requesting from a live site.

Not sure if any of that is helpful, but I figured I'd throw the info out in case it helps.

jesseditson added a commit to jesseditson/testling that referenced this issue Mar 3, 2013
@jesseditson
Copy link

The above fix solves this - looks like node is sending a string as content-length, which causes the content-length to be wrong, and the request fails. I'm seeing this in express 3.x, but if @AndreasMadsen's example fails as well, it may be lower level. In any case, a quick parseInt in proxy.js fixes this.

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

No branches or pull requests

2 participants