request/lib/octet_parser.js

18 lines
331 B
JavaScript

import { EventEmitter } from 'events'
import util from 'util'
export function OctetParser() {
EventEmitter.call(this)
}
util.inherits(OctetParser, EventEmitter)
OctetParser.prototype.write = function(buffer) {
this.emit('data', buffer)
return buffer.length
}
OctetParser.prototype.end = function() {
this.emit('end')
}
对Http的request进一步封装, 提供常用的API
JavaScript 100%