xiamx / ssr-proxy

Prerender your single page app for better SEO and support on legacy browsers
MIT License
40 stars 3 forks source link

throw new TypeError('The header content contains invalid characters') #6

Open antsn opened 7 years ago

antsn commented 7 years ago

I use node version 8.6, when running (with default settings): ssr-proxy --config config.json

Using browser Opera 12.16, enter the address, such as: http://www.imdb.com/title/tt3890160/reviews?start=10

At first, the proxy crash:

[SSR-Proxy] Request http://www.imdb.com/title/tt3890160/reviews?start=10
[SSR-Proxy] Request http://sitecheck2.opera.com/?host=www.imdb.com&hdn=7PaO23WiGu/TsGcxLWYK3w==
[Phantom] Page Created
[Phantom] Page Created
[Phantom] will open page http://www.imdb.com/title/tt3890160/reviews?start=10
[Phantom] will open page http://sitecheck2.opera.com/?host=www.imdb.com&hdn=7PaO23WiGu/TsGcxLWYK3w==
[Phantom] Resource Received http://sitecheck2.opera.com/?host=www.imdb.com&hdn=7PaO23WiGu/TsGcxLWYK3w==
_http_server.js:188
    throw new RangeError(`Invalid status code: ${originalStatusCode}`);
    ^

RangeError: Invalid status code: null
    at ServerResponse.writeHead (_http_server.js:188:11)
    at Proxy.page.on (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/src/index.js:50:25)
    at EventEmitter.<anonymous> (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/node_modules/phantom/lib/phantom.js:308:33)
    at emitOne (events.js:115:13)
    at EventEmitter.emit (events.js:210:7)
    at Stream.Phantom.process.stdout.pipe.on.data (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/node_modules/phantom/lib/phantom.js:165:34)
    at emitOne (events.js:115:13)
    at Stream.emit (events.js:210:7)
    at drain (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/node_modules/through/index.js:45:5)

I tried again, this time, it crash and show error:

[SSR-Proxy] Request http://www.imdb.com/title/tt3890160/reviews?start=10
[Phantom] Page Created
[Phantom] will open page http://www.imdb.com/title/tt3890160/reviews?start=10
[Phantom] Resource Received http://www.imdb.com/title/tt3890160/reviews?start=10
_http_outgoing.js:434
      throw new TypeError('The header content contains invalid characters');
      ^

TypeError: The header content contains invalid characters
    at storeHeader (_http_outgoing.js:434:13)
    at ServerResponse._storeHeader (_http_outgoing.js:346:7)
    at ServerResponse.writeHead (_http_server.js:251:8)
    at Proxy.page.on (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/src/index.js:50:25)
    at EventEmitter.<anonymous> (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/node_modules/phantom/lib/phantom.js:308:33)
    at emitOne (events.js:115:13)
    at EventEmitter.emit (events.js:210:7)
    at Stream.Phantom.process.stdout.pipe.on.data (/usr/local/n/versions/node/8.6.0/lib/node_modules/ssr-proxy/node_modules/phantom/lib/phantom.js:165:34)
    at emitOne (events.js:115:13)
    at Stream.emit (events.js:210:7)
antsn commented 7 years ago

It seems that phantomjs could not handle cookies contains 'backward slash' '\' character

xiamx commented 7 years ago

Ah maybe a new version of phantomjs can solve this issue. Or perhaps this project can be updated to use chrome headless