Closed AoDev closed 10 years ago
Hi @AoDev You are correct the mime-type isn't checked. If you can provide the HTML file/site you are trying to proxy and the selector code you are using we can have a closer look. Thanks
Hello,
Here is the whole story:
What I want to do is to inject some code to the body of a webpage, for development purpose. Because it's the only way we found to test a feature in mobile browsers. So we want to intercept the response and inject our development code.
To test Harmon, let's take this site: http://kevinpurnelle.com/ (it's mine) And for this page for example: http://kevinpurnelle.com/jobs/yuhubox/
Replace the element with the 'date' class.
simpleselect.query = '.date';
simpleselect.func = function (node) {
node.createWriteStream().end('<div>Proxied</div>');
}
Just now, I saw I got a different error. The buffer error was with a local version of the same site. With this online version I get:
events.js:72
throw er; // Unhandled 'error' event
^
Error: Unexpected end
Line: 3
Column: 117
Char:
at error (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/sax/lib/sax.js:642:8)
at end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/sax/lib/sax.js:650:64)
at Object.SAXParser.end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/sax/lib/sax.js:149:24)
at SAXStream.end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/sax/lib/sax.js:234:16)
at Stream.<anonymous> (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/lib/tokenize.js:20:30)
at _end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/through/index.js:65:9)
at Stream.stream.end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/through/index.js:74:5)
at Stream.<anonymous> (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/index.js:22:30)
at _end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/through/index.js:65:9)
at Stream.stream.end (/Users/AoDev/git-repos/ssp-proxy/node_modules/harmon/node_modules/trumpet/node_modules/through/index.js:74:5)
So I replicated the error and the response doesn't seem to be getting past
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Kevin Purnelle Personal website</title>
<meta name="viewport" content="width=device-width">
<!-- Custom CSS -->
<link rel="stylesheet"
I can't seem to replicate this on any other site. Can you give some indication to the type of server that is serving this content?
Thanks
And when I use the content from my browser directly into the default HTTP server given in the sample I can't replicate the issue.
So I have added the option to ignore CSS and JS files that should help with general site work. It inspects the file extension as mime-type was proving flaky Reference implementation here https://github.com/No9/harmon/blob/master/examples/doge.js Closing this
Hello,
I was trying harmon and the example works very well. I'm pretty new to this but I then tried it with a real server and I get a oob exception from trumpet (Out of buffer). I am not sure, but I think that it's because harmon does not check if the response is actually html and will run trumpet on any proxied file. But I am very new to this so maybe it's not that.
It probably should check for Content-Type: text/html in headers or simply can you tell me where I'm wrong.
Here is the exception: