Permalink
Browse files

ported the cplusplus plugin to the new api

  • Loading branch information...
1 parent f96ebd2 commit 6dad7b3cedf62822fecc1aedf0e20a207723f103 @unbit committed Mar 29, 2013
Showing with 9 additions and 7 deletions.
  1. +6 −4 plugins/cplusplus/base.cc
  2. +1 −1 plugins/cplusplus/plugin.c
  3. +2 −2 uwsgi.h
@@ -1,4 +1,4 @@
-#include "../../uwsgi.h"
+#include <uwsgi.h>
extern struct uwsgi_server uwsgi;
@@ -13,8 +13,9 @@ class FakeClass {
void FakeClass::hello_world(struct wsgi_request *wsgi_req) {
- wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, (char *) "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n", 44);
- wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, foobar, foobar_len);
+ uwsgi_response_prepare_headers(wsgi_req, (char *)"200 OK", 6);
+ uwsgi_response_add_content_type(wsgi_req, (char *)"text/html", 9);
+ uwsgi_response_write_body_do(wsgi_req, foobar, foobar_len);
}
extern "C" int uwsgi_cplusplus_init(){
@@ -27,7 +28,7 @@ extern "C" int uwsgi_cplusplus_request(struct wsgi_request *wsgi_req) {
FakeClass *fc;
// empty request ?
- if (!wsgi_req->uh.pktsize) {
+ if (!wsgi_req->uh->pktsize) {
uwsgi_log( "Invalid request. skip.\n");
goto clear;
}
@@ -55,6 +56,7 @@ extern "C" int uwsgi_cplusplus_request(struct wsgi_request *wsgi_req) {
extern "C" void uwsgi_cplusplus_after_request(struct wsgi_request *wsgi_req) {
+ // call log_request(wsgi_req) if you want a standard logline
uwsgi_log("logging c++ request\n");
}
@@ -1,4 +1,4 @@
-#include "../../uwsgi.h"
+#include <uwsgi.h>
int uwsgi_cplusplus_init(void);
View
@@ -3902,8 +3902,8 @@ char *uwsgi_get_header(struct wsgi_request *, char *, uint16_t, uint16_t *);
void uwsgi_alarm_thread_start(void);
void uwsgi_exceptions_handler_thread_start(void);
-#define uwsgi_response_add_connection_close(x) uwsgi_response_add_header(x, "Connection", 10, "close", 5)
-#define uwsgi_response_add_content_type(x, y, z) uwsgi_response_add_header(x, "Content-Type", 12, y, z)
+#define uwsgi_response_add_connection_close(x) uwsgi_response_add_header(x, (char *)"Connection", 10, (char *)"close", 5)
+#define uwsgi_response_add_content_type(x, y, z) uwsgi_response_add_header(x, (char *)"Content-Type", 12, y, z)
struct uwsgi_stats_pusher_instance *uwsgi_stats_pusher_add(struct uwsgi_stats_pusher *, char *);

0 comments on commit 6dad7b3

Please sign in to comment.