mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 20:31:25 +00:00
add support for charsets other than gbk
This commit is contained in:
parent
3dc255e4de
commit
631b6307ce
@ -1,4 +1,8 @@
|
|||||||
22 Jan 2015: anyproxy 3.1.1:
|
28 Jan 2015: anyproxy 3.1.2:
|
||||||
|
|
||||||
|
* thanks to iconv-lite, almost webpage with any charset can be correctly decoded in web interface.
|
||||||
|
|
||||||
|
28 Jan 2015: anyproxy 3.1.1:
|
||||||
|
|
||||||
* convert GBK to UTF8 in web interface
|
* convert GBK to UTF8 in web interface
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ Feature
|
|||||||
* work as http or https proxy
|
* work as http or https proxy
|
||||||
* fully configurable, you can modify a request at any stage by your own javascript code
|
* fully configurable, you can modify a request at any stage by your own javascript code
|
||||||
* when working as https proxy, it can generate and intercept https requests for any domain without complaint by browser (after you trust its root CA)
|
* when working as https proxy, it can generate and intercept https requests for any domain without complaint by browser (after you trust its root CA)
|
||||||
* a web interface is availabe for you to view request details
|
* a web interface for you to watch realtime request details, where html string with (almost) any charset could be shown correctly
|
||||||
* (beta)a web UI interface for you to replace some remote response with local data
|
* (beta)a web UI interface for you to replace some remote response with local data
|
||||||
|
|
||||||

|

|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "anyproxy",
|
"name": "anyproxy",
|
||||||
"version": "3.1.1",
|
"version": "3.1.2",
|
||||||
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
||||||
"main": "proxy.js",
|
"main": "proxy.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
11
proxy.js
11
proxy.js
@ -156,9 +156,16 @@ function proxyServer(option){
|
|||||||
bodyContent = GLOBAL.recorder.getBody(data.id);
|
bodyContent = GLOBAL.recorder.getBody(data.id);
|
||||||
|
|
||||||
result = bodyContent;
|
result = bodyContent;
|
||||||
if(/charset=gbk/i.test(JSON.stringify(resHeader))){
|
//detect charset and convert to utf8 for web interface
|
||||||
result = iconv.decode(bodyContent, 'GBK');
|
try{
|
||||||
|
var charsetMatch = JSON.stringify(resHeader).match(/charset="?([a-zA-Z0-9\-]+)"?/);
|
||||||
|
if(charsetMatch && charsetMatch.length > 1){
|
||||||
|
var currentCharset = charsetMatch[1].toLowerCase();
|
||||||
|
if(currentCharset != "utf-8" && iconv.encodingExists(currentCharset)){
|
||||||
|
result = iconv.decode(bodyContent, currentCharset);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}catch(e){}
|
||||||
|
|
||||||
child_webServer.send({
|
child_webServer.send({
|
||||||
type : "body",
|
type : "body",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user