Permalink
Browse files

fixed bug

* replace url of http request when static serving required
* add error handling for static serving
  • Loading branch information...
zentooo committed Nov 9, 2010
1 parent 5583da5 commit 6eb38ea4f352290fc803382f07f5d061c076d51c
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/http-proxy-selective.js
@@ -28,7 +28,16 @@ function handle(req, res) {
staticServer = (statics[url.host]) ? statics[url.host][trimslash(splat.dirname)] : null;
if ( staticServer ) {
- staticServer.serve(req, res);
+ req.url = splat.filename;
+
+ staticServer.serve(req, res, function(err, result) {
+ if (err) {
+ util.error("Error serving " + staticServer.root + splat.filename + " - " + err.message);
+
+ res.writeHead(err.status, err.headers);
+ res.end();
+ }
+ });
console.log("selective: ".yellow + "replaced " + url.href.red + " with local file: " + (staticServer.root + splat.filename).green);
}
else {

0 comments on commit 6eb38ea

Please sign in to comment.