我正在用Javascript开发一个类,该类将获取作为参数传递给构造函数的URL的HTML。我有点坚持要实现的各种方法。寻找建议。
class HttpConnection extends EventEmitter {
/* HttpConnectionManager class creates an object and passes an URL that needs to be fetched as a parameter to the constructor */
constructor (url, userAgent) {
}
/* fetch URL, send HTTP request and return its HTML body. TBD the return format */
fetchUrl () {
}
/* Update statistics based on the result returned bu the HTTP request, as well as logging an error if one occurs */
updateStats () {
}
/* close the connection and return true if connection is now closed */
cleanUp (request) {
}
}
module.exports = HttpConnection
到目前为止,这些是已经实现的方法。 fetchUrl()方法有点长,所以我在考虑将其分成几种方法。