Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove tmp file; remove casing check from parser.

  • Loading branch information...
commit cfdf0e28b1374367618d6b5c6c33a44e28edf806 1 parent 3ee6748
@omphalos authored
View
1  .gitignore
@@ -1 +1,2 @@
*~
+*.kate-swp
View
39 goblin.js
@@ -4,10 +4,10 @@ function Buffer(res) {
var self = this
+ self.headers = {}
self.res = res
self._chunks = []
- self._headers = {}
///////////////////////////////
// monkey patch the response //
@@ -24,7 +24,7 @@ function Buffer(res) {
res.writeHead = function(statusCode, headers) {
- self._headers = headers
+ self.headers = headers
self._statusCode = statusCode
res.emit('writeHead', headers, statusCode)
@@ -45,39 +45,10 @@ function Buffer(res) {
}
}
-////////////
-// helper //
-////////////
-
-Buffer.prototype._resolveHeaderName = function resolveHeaderName(header) {
-
- var headers = Object.keys(this._headers)
- var match = headers.
- map(function(h) { return h.toLowerCase() }).
- indexOf(header.toLowerCase())
- return headers[match] || header
-}
-
//////////////////////
// public interface //
//////////////////////
-Buffer.prototype.setHeader = function(header, value) {
- this._headers[this._resolveHeaderName(header)] = value
-}
-
-Buffer.prototype.getHeader = function getHeader(header) {
- return this._headers[this._resolveHeaderName(header)]
-}
-
-Buffer.prototype.deleteHeader = function removeHeader(header) {
- delete this._headers[this._resolveHeaderName(header)]
-}
-
-Buffer.prototype.getHeaders = function getHeaders() {
- return this._headers
-}
-
Buffer.prototype.getData = function getData() {
return this._data || this._chunks.join('')
}
@@ -90,8 +61,10 @@ Buffer.prototype.send = function send() {
var data = this.getData()
- this.setHeader('Content-Length', data.length)
- this._writeHead.call(this.res, this._statusCode, this._headers)
+ if(this._data)
+ this.headers['content-length'] = data.length
+
+ this._writeHead.call(this.res, this._statusCode, this.headers)
this._end.call(this.res, data, this._encoding)
}
View
BIN  hosts/.proxy.js.kate-swp
Binary file not shown
View
3  hosts/proxy.js
@@ -18,11 +18,10 @@ module.exports = function(options) {
return http.createServer(function(req, res) {
var buffer = new goblin.Buffer(res)
-
res.on('end', function() {
// insert the script into the outgoing html
- if(buffer.getHeader('Content-Type') === 'text/html') {
+ if(buffer.headers['content-type'] === 'text/html') {
$ = cheerio.load(buffer.getData())
var root = $('body').length ? $('body') : $.root
Please sign in to comment.
Something went wrong with that request. Please try again.