No9 / harmon

middleware for node-http-proxy to modify the remote website response with trumpet
Other
424 stars 62 forks source link

Issue with simple external proxing with Harmon #3

Closed jamesla closed 11 years ago

jamesla commented 11 years ago

Hi I am trying to make a simple external proxy POC however am having issues with Harmon returning strange data.

I have written the following code and simplified it to illustrate what is happening. Ignore the fact that I am passing harmon an empty action as it does the same thing with a valid action (the action does work if it is passed in) however I am omitting it for the sake of simplicity in this example. More details in comments for each server below.

var http = require('http'), httpProxy = require('http-proxy');

/* If a client connects to this server plan text web pages will work fine however most web sites will hang half way through loading, images won't load and will generally display wrong */ httpProxy.createServer( require('harmon')([], []), 9000, 'localhost' ).listen(8000);

/* If client connects directly to this server node http proxy will proxy as expected. - so node http proxy must be working as expected. */ httpProxy.createServer(function (req, res, proxy) { proxy.proxyRequest(req, res, { host: req.headers.host, port: 80 }); }).listen(9000);

Basically the page will load however the data will be distorted and sometimes the node server will hang.

I have read through the examples and looked at the source but can't work out what is happening if anybody could enlighten me that would be great!

No9 commented 11 years ago

Can you give me a sample URL please. There may be an issue with Trumpet as it is due an upgrade

jamesla commented 11 years ago

Sure any http website that is not 100% plain text will do it.

I have confirmed www.reddit.com will do it (content encoding error in firefox is the exact error I am getting).

jamesla commented 11 years ago

Anton it looks like a great project, are you able to recommend me version numbers of both trumpet and harmon that are confirmed to be working together?

No9 commented 11 years ago

Thanks for the nice comments. As per the package.json https://github.com/No9/harmon/blob/master/package.json#L25 "trumpet": "0.3.1" with version 0.1.0 of harmon.