Skip to content
This repository
Browse code

cachemodule fix for CGI mode, readme updated.

  • Loading branch information...
commit 306cf9c8be33bb918eee2c37eb3a3a5737807088 1 parent 4f87a73
vixns vixns authored
5 Readme.md
Source Rendered
@@ -8,6 +8,7 @@ For more documentation visit the [hxfcgi](http://haxe.org/com/libs/hxfcgi) wiki
8 8
9 9 Differences to haxe Web API:
10 10 ----------------------------
11   -* If you using FastCGI you should use `Web.cacheModule()`, otherwise the module will be restarted after every request, which is quite slow.
12   -* If you using CGI if does not matter if you use `Web.cacheModule()`.
  11 +* If you are using FastCGI you should use `Web.cacheModule()`, otherwise the module will be restarted after every request, which is quite slow.
  12 +* If you are using CGI if does not matter if you use `Web.cacheModule()`.
  13 +* When setting cache with `Web.cacheModule(run)`, `run` is called, don't call your `run` method after caching or it may run twice.
13 14 * You need to print some data, when sending headers only, call `Lib.print('');` after setting all headers.
3  src/hxfcgi.cpp
@@ -25,6 +25,7 @@
25 25 #include "basic.h"
26 26 #include "data.h"
27 27
  28 +#include <fcgi_stdio.h>
28 29
29 30 DEFINE_KIND(hxRequest);
30 31
@@ -40,7 +41,6 @@ while( *cursor != 0 && *cursor != '\r' && *cursor != '\n' && *cursor != '\t' ) \
40 41 cursor++; \
41 42 }
42 43
43   -
44 44 inline hxfcgi::Request* get_request(value hreq) {
45 45 val_check_kind(hreq,hxRequest);
46 46 return (hxfcgi::Request*)val_data(hreq);
@@ -93,6 +93,7 @@ value hxfcgi_cache_module(value func) {
93 93 hxfcgi::Request *req;
94 94 while (true) {
95 95 try {
  96 + if(FCGX_IsCGI()) break;
96 97 req = new hxfcgi::Request();
97 98 val_call1(func,alloc_abstract(hxRequest,req));
98 99 delete req;
3  src/request.cpp
@@ -26,13 +26,12 @@
26 26 #include "data.h"
27 27
28 28 namespace hxfcgi {
29   -
  29 +
30 30 Request::Request() {
31 31 header_sent = false;
32 32 post_fetched = false;
33 33 postData = "";
34 34 if (!FCGI_Accept()==0) {
35   - if(FCGX_IsCGI()) exit(1);
36 35 string error = "Could not generate Request";
37 36 throw error;
38 37 }
2  test/Example.hx
@@ -10,7 +10,7 @@ class Example {
10 10
11 11 static function main() {
12 12 Web.cacheModule(run);
13   - run();
  13 + //run();
14 14 }
15 15
16 16 static function run() {
2  test/Test.hx
@@ -11,7 +11,7 @@ class Test {
11 11
12 12 static function main() {
13 13 Web.cacheModule(run);
14   - run();
  14 + //run();
15 15 }
16 16
17 17 static function run() {

0 comments on commit 306cf9c

Please sign in to comment.
Something went wrong with that request. Please try again.