Skip to content

Commit

Permalink
Merge pull request #339 from Tencent/v1.4.3
Browse files Browse the repository at this point in the history
V1.4.3
  • Loading branch information
RobinzZH authored Sep 29, 2019
2 parents dabfe78 + 97ea641 commit 6301c68
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 21 deletions.
3 changes: 2 additions & 1 deletion bin/proxy/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function bind_listen(server) {
logger.debug('ws server error:' + (error && error.stack));
});

server.on('connection', function(ws) {
server.on('connection', function(ws, request) {
ws.upgradeReq = ws.upgradeReq || request;
process.SN = process.SN || 0;
let d = domain.create();
d.add(ws);
Expand Down
11 changes: 11 additions & 0 deletions bin/tsw/default/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ this.modMap = {
}
};

// 配置默认的名称和路由信息,方便新人理解
this.router = {
name: function() {
return 'default';
},
find: function() {
const res = window.response;
res.end('route to config.default.js');
}
};

this.isCloud = false;

this.page419 = null;
Expand Down
10 changes: 5 additions & 5 deletions bin/tsw/runtime/capturer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ process.nextTick(function() {

let requestBody = '';

if( request._body ){
if(request._body.length < maxBodySize){
requestBody = request._body.toString('base64')
}else{
requestBody = Buffer.from(`body was too large too show, length: ${request._body.length}`).toString('base64')
if (request._body) {
if (request._body.length < maxBodySize) {
requestBody = request._body.toString('base64');
} else {
requestBody = Buffer.from(`body was too large too show, length: ${request._body.length}`).toString('base64');
}
}

Expand Down
8 changes: 3 additions & 5 deletions bin/tsw/util/auto-report/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ const initRequestHar = function (request) {
}
}
});
if (request.method && request.method === 'POST') {
const postDataArr = requestArr[requestArr.length - 1];
request.postData.mimeType = 'multipart/form-data';
request.postData.text = postDataArr;
}


const postDataArr = requestArr[requestArr.length - 1];
request.postData.text = postDataArr;

}
}
// 补齐cookie
Expand Down
18 changes: 9 additions & 9 deletions bin/tsw/util/auto-report/logReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ module.exports.reportLog = function() {
headers: httpUtil.getRequestHeaderStr(req),
body: requestBodyText,
statusCode: res.statusCode,
resHeaders: JSON.stringify(res._headers, null, 2)
resHeaders: JSON.stringify(res.getHeaders())
});
}

Expand All @@ -697,16 +697,16 @@ module.exports.reportLog = function() {
try {

// webapp的二进制回包转成可视化的结构
if (!isWebSocket && res._body && res._headers['content-type'] === 'webapp') {
if (!isWebSocket && res._body && res.getHeader('content-type') === 'webapp') { // 不要用_headers了
res._body = Buffer.from(format.formatBuffer(res._body));
}

let requestBody = '';

if (req._body){
if (req._body.length < maxBodySize){
requestBody = req._body.toString('base64')
}else{
if (req._body) {
if (req._body.length < maxBodySize) {
requestBody = req._body.toString('base64');
} else {
requestBody = Buffer.from(`body was too large too show, length: ${req._body.length}`).toString('base64');
}
}
Expand All @@ -718,8 +718,8 @@ module.exports.reportLog = function() {
cache: '',
process: 'TSW:' + process.pid,
resultCode: (res && res.statusCode) || 101,
contentLength: isWebSocket ? 0 : (res._headers['content-length'] || res._bodySize),
contentType: isWebSocket ? 'websocket' : res._headers['content-type'],
contentLength: isWebSocket ? 0 : (res.getHeader('content-length') || res._bodySize),
contentType: isWebSocket ? 'websocket' : res.getHeader('content-type'),
clientIp: httpUtil.getUserIp(req),
clientPort: req.socket && req.socket.remotePort,
serverIp: serverInfo.intranetIp,
Expand Down Expand Up @@ -758,7 +758,7 @@ module.exports.reportLog = function() {
const pathName = req.REQUEST.pathname;
const fileName = pathName.substr(pathName.lastIndexOf('/') + 1);
reportData.group = module.exports.fingureCroup({
resHeaders: res._headers,
resHeaders: res.getHeaders(),
reqHeaders: req.headers,
suffix: fileName.indexOf('.') !== -1 ? fileName.substr(fileName.lastIndexOf('.') + 1) : '',
method: req.method,
Expand Down
32 changes: 32 additions & 0 deletions changeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# ChangeLog

## [2019-09-29, Version v1.4.3](/~https://github.com/Tencent/TSW/releases/tag/v1.4.3)


### Bug fixes

- [[```1f9ba814```](/~https://github.com/Tencent/TSW/commit/1f9ba814563ddf26e050f8114eaf5a627a2ae6f0)] __-__ __eslint__: lint code (robinzhxie)
- [[```bf14d6ea```](/~https://github.com/Tencent/TSW/commit/bf14d6eaeaaa8d013d8970624906b87b9b19f74b)] __-__ __websocket__: fix websocket url not defined error (hazelchen)
- [[```99575bbb```](/~https://github.com/Tencent/TSW/commit/99575bbbbaec4f8a40fa2f2c7504b8713028cafe)] __-__ fix har log (yinghaowang)
- [[```0d42babb```](/~https://github.com/Tencent/TSW/commit/0d42babb7ac4d703c6e7cf22b5bb7eb0de503944)] __-__ add default router config (jackqqxu)
- [[```b599f506```](/~https://github.com/Tencent/TSW/commit/b599f50665a15402b50b990392603358a857bbb5)] __-__ add default router config (jackqqxu)
- [[```2eba668e```](/~https://github.com/Tencent/TSW/commit/2eba668e4474ed086c171947457a944670d29929)] __-__ outgoingMessage.prototype._headers is deprecated (jackqqxu)
- [[```379bad0c```](/~https://github.com/Tencent/TSW/commit/379bad0c8d5f8c52612a4a564a6bc0a73100321f)] __-__ outgoingMessage.prototype._headers is deprecated (jackqqxu)
- [[```573ab47a```](/~https://github.com/Tencent/TSW/commit/573ab47a2226695d9f9b803e89c1fc8567bade87)] __-__ outgoingMessage.prototype._headers is deprecated (jackqqxu)




## [2019-09-29, Version v1.4.2](/~https://github.com/Tencent/TSW/releases/tag/v1.4.2)


### Bug fixes

- [[```173829bb```](/~https://github.com/Tencent/TSW/commit/173829bb3ad614d233d8193b7b58303e79a0b0a5)] __-__ upgrade version to match npm (robinzhxie)


### Other commits

- [[```9243c944```](/~https://github.com/Tencent/TSW/commit/9243c94489e94a6d143803d9bc9f5781c7277195)] __-__ __docs__ : update change log (robinzhxie)




## [2019-07-19, Version v1.4.1](/~https://github.com/Tencent/TSW/releases/tag/v1.4.1)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tswjs/tsw",
"version": "1.4.1",
"version": "1.4.3",
"description": "A Node.js infrastructure which is designed for improving the efficiency of locating problems, providing multiple functions for front-end developers",
"scripts": {
"lint": "eslint examples bin test --fix",
Expand Down

0 comments on commit 6301c68

Please sign in to comment.