int httpconnection_on_status_complete(http_parser* p) {
  HTTPConnection* c = static_cast<HTTPConnection*>(p->data);
  if(c->cb_event) {
    c->cb_event(c, HTTP_ON_STATUS, NULL, 0, c->cb_event_user);
  }  
  return 0;
}
int httpconnection_on_message_complete(http_parser* p) {
  HTTPConnection* c = static_cast<HTTPConnection*>(p->data);
  if(c->cb_event) {
    c->cb_event(c, HTTP_ON_COMPLETE, NULL, 0, c->cb_event_user);
  }
  
  return 0;
}
int httpconnection_on_body(http_parser* p, const char* at, size_t len) {

  HTTPConnection* c = static_cast<HTTPConnection*>(p->data);
  if(c->cb_event) {
    c->cb_event(c, HTTP_ON_BODY, at, len, c->cb_event_user);
  }

  return 0;
}
void httpconnection_on_close(uv_handle_t* handle) {
  HTTPConnection* c = static_cast<HTTPConnection*>(handle->data);

  delete handle;
  handle = NULL;

  if(c->cb_event) {
    c->cb_event(c, HTTP_ON_CLOSED, NULL, 0, c->cb_event_user);
  }
  
  if(c->cb_close) {
    c->cb_close(c, HTTP_ON_CLOSED, NULL, 0, c->cb_close_user);
  }
}