Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updating

  • Loading branch information...
commit 98495df3d953070ba6aac777d0347bbc5ba5e7f3 1 parent 42a81ce
@d5 authored
Showing with 20 additions and 3 deletions.
  1. +17 −1 native/http.h
  2. +2 −2 versioninfo.md
  3. +1 −0  webserver.cpp
View
18 native/http.h
@@ -46,6 +46,10 @@ namespace native
registerEvent<event::data>();
registerEvent<event::end>();
registerEvent<event::close>();
+
+ socket_->on<event::data>([this](const Buffer& buffer){ emit<event::data>(buffer); });
+ socket_->on<event::end>([this](){ emit<event::end>(); });
+ socket_->on<event::close>([this](){ emit<event::close>(); });
}
virtual ~ServerRequest()
@@ -90,6 +94,9 @@ namespace native
assert(socket_);
registerEvent<event::close>();
+ registerEvent<event::error>();
+
+ socket_->on<event::close>([this](){ emit<event::close>(); });
}
virtual ~ServerResponse()
@@ -116,7 +123,16 @@ namespace native
void end(const Buffer& data)
{
- socket_->end(data);
+ assert(socket_);
+
+ if(socket_->end(data))
+ {
+ socket_ = nullptr;
+ }
+ else
+ {
+ emit<event::error>(Exception("Failed to close the socket."));
+ }
}
private:
View
4 versioninfo.md
@@ -8,6 +8,6 @@ Current port is based on the following node version:
### Dependencies
-- [libuv](https://github.com/joyent/libuv): https://github.com/joyent/libuv/commit/75ab1ba77467cab272ee8302ca4e9d1be306d2f6
-- [http-parser](https://github.com/joyent/http-parser): https://github.com/joyent/http-parser/commit/62110efe7ae268d6e6435ac0e7e7690c0e998655
+- [libuv](https://github.com/joyent/libuv): https://github.com/joyent/libuv/commit/2ef5798c6f0513914bf83aa910b2535d9a1d5948
+- [http-parser](https://github.com/joyent/http-parser): https://github.com/joyent/http-parser/commit/36808f4fad0d6ccda8ee0d5e199fe30691242952
View
1  webserver.cpp
@@ -9,6 +9,7 @@ int main(int argc, char** argv) {
});
server->on<event::request>([](http::ServerRequest* req, http::ServerResponse* res){
std::cout << "request" << std::endl;
+ res->end(Buffer(std::string("path: ")+req->path()+"\r\n"));
});
server->on<event::error>([](const Exception& e){
std::cout << "error: " << e.message() << std::endl;
Please sign in to comment.
Something went wrong with that request. Please try again.