Package for edp webserver.
ecomfe / edp-webserver Goto Github PK
View Code? Open in Web Editor NEWPackage for edp webserver.
Package for edp webserver.
如后端认定的URL是static/xxx.html
,对FE来说应该是${DOC_ROOT}/xxx.html
,因此最好能这么配:
{
location: /static\//,
handler: dir('.')
}
如题。
edp test 调用 webserver 时,我希望可以保证控制台的干净。
文件太大了,把各个handler独立出来,另外增加了对edp-core
的依赖,日志输出的时候使用edp.log
现在less等一些编译脚本,如果less文件有语法错误,不会打印出错误信息,很难排查问题
打印出错误日志
如果是node http client 请求的时候会报 parse error,proxy.js 实际上是全部数据返回后在怼给客户端的,可以移除'transfer-encoding': 'chunked'
minimatch 的功能:
Supports these glob features:
See:
这规则还蛮通用的,包括 .gitignore
、grunt
等,就是常见的 /a/**/*.js
形式(匹配所有 a
目录及其子目录下后缀为 js
的文件)。
信息如下
Gray's MacBook Pro:cb-web-2 otakustay$ ws
EDP WebServer start, root = [/Users/otakustay/Dev/cb-web-2], listen = [8080]
[2013/7/2 11:9:11] Forward request localhost:8080/favicon.ico to 10.81.57.15:8080/favicon.ico
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:883:11)
at Object.afterConnect [as oncomplete] (net.js:874:19)
此时远程机网络无法连通,但本地测试也没需要远程机,就因为一个favicon挂了……
首先,当使用proxy
资源时,会改写真正发到远端服务器的请求中的Host
头:https://github.com/ecomfe/edp-webserver/blob/master/lib/resource.js#L689
这个在实际应用中存在问题,有些后端的跳转(response.redirect
)会根据这个Host
头给出Location
响应头的内容,这会导致302返回的Location
头不合预期,因此要去掉这行代码
其次,发现返回时Content-Type
头有重复,一个是正常的,一个是undefined
同时各header也变成小写的了,这在验证一些HTTP头时非常具有干扰性,应当保持 完全一致
Error: Cannot set deprecated header: connection
at OutgoingResponse.setHeader (/usr/local/lib/node_modules/edp-webserver/node_modules/http2/lib/http.js:367:13)
at OutgoingResponse.writeHead (/usr/local/lib/node_modules/edp-webserver/node_modules/http2/lib/http.js:716:10)
at /usr/local/lib/node_modules/edp-webserver/lib/resource.js:52:34
at Gzip.onEnd (zlib.js:227:5)
at Gzip.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickDomainCallback (node.js:381:11)
RT
如果 Content-Range
没有这货 ,IOS 视频无法播放
在调用子进程时,handler是执行的php命令,需要解析的php文件参数并没有被子进程使用,效果是只执行不带参数php ,导致php模块不可用~@leeight
var child = require('child_process').spawn( handler, [], { env: env } );
最近在使用webserver调用php时发现几个问题:
opt_forwardPathName的定义是只提供修改pathname的功能,但实际上很可能同时存在修改search的需要。比如将所有php请求都转给index.php处理,这需要修改pathname,同时在search中添加参数pathname=xxx;
希望能将此参数重新定义,可以有两个方向:
比如
{
pathname: '/index.php',
search: '?a=1&pathname=/some/where'
}
child.stderr的end事件处理
chunk为空也会触发end
事件。
node版本是0.10.26, mac OSX 10.92
对Content-Length
的处理有问题,导致POST请求超时。
if ('content-length' in request.headers) {
env.CONTENT_LENGTH = request.headers['content-length'];
}
目前的逻辑是在header中有Content-Length
就加上,没有就算了。在实际测试中,浏览器可能不发这个。
比如:
$.post(conf.uiRoot + '/trade/fund/buy', $(this).serialize()).then(function (result) {
console.log(result);
}, function (error) {
console.log(error);
});
浏览器Chrome 34.0.1847.13, mac OSX 10.92
由于没有Content-Length
,导致php-cgi一直等待,直到超时结束。
按照这篇文章的分析,可以把对php-cgi
的调用模式直接设定为Transfer-Encoding: Chunked
,而不计算Content-Length
。
mac上测试没有问题 ,windows上未知。
RT
如题,应该支持和proxy
一样的配置
RT,目前每次都要缩放之后才能点到,稍微响应式一下。
proxy handler中,请求头中使用目标host
覆盖原本的host
,否则会导致被目标host给屏蔽
在edp-webserver-config.js
中配置header会出错
{
location: /^.*$/,
handler: header({
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'X-Requested-With',
'Access-Control-Allow-Methods': 'GET,POST,OPTIONS'
})
}
经查,在resource.js中添加header处理函数,错误地使用了mix.js,导致报错。
应当将mix.js作如下修改
// @file mix.js
module.exports = function () {
// ...
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.