Skip to content

Commit 326a09f

Browse files
committed
prepare for v0.4.4
1 parent 0fac5be commit 326a09f

File tree

8 files changed

+238
-40
lines changed

8 files changed

+238
-40
lines changed

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Downloads & Release History
44
1. [Binaries of Releases](http://sourceforge.net/projects/nginx-clojure/files/)
55
1. [Sources of Releases](https://github.com/nginx-clojure/nginx-clojure/releases)
66

7+
## 0.4.4 (2016-03-04)
8+
9+
1. New Feature: experimental nginx body filter by Java/Clojure/Groovy (issue #107)
10+
1. New Feature: read request body by event callback (issue #109)
11+
1. Bug Fix: 500 (internal server error) returns when committing 2000+ files to nginx as a proxy for apache mod_dav_svn (issue #106)
12+
713
## 0.4.3 (2015-10-25)
814
1. New Feature: Add directive [jvm_classpath][] which supports wildcard character * (issue #95)
915
1. New Feature: Add directive [jvm_classpath_check][] which is enabled by default and when it is enabled access permission about classpaths will be checked.

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
Core Features
88
=================
99

10-
The latest release is v0.4.3, more detail changes about it can be found from [Release History](//nginx-clojure.github.io/downloads.html).
10+
The latest release is v0.4.4, more detail changes about it can be found from [Release History](//nginx-clojure.github.io/downloads.html).
1111

1212
1. Compatible with [Ring](https://github.com/ring-clojure/ring/blob/master/SPEC) and obviously supports those Ring based frameworks, such as Compojure etc.
1313
1. Http Services by using Clojure / Java / Groovy to write simple handlers for http services.
1414
1. Nginx Access Handler by Clojure / Java / Groovy
1515
1. Nginx Header Filter by Clojure / Java / Groovy
16-
1. **_NEW_**: Pub/Sub Among Nginx Worker Processes
17-
1. **_NEW_**: Shared Map based on shared memory & Shared Map based Ring session store
18-
1. **_NEW_**: Support Sente, see [this PR](https://github.com/ptaoussanis/sente/pull/160)
19-
1. **_NEW_**: Support Per-message Compression Extensions (PMCEs) for WebSocket
16+
1. **_NEW_**: Nginx Body Filter by Clojure / Java / Groovy
17+
1. Pub/Sub Among Nginx Worker Processes
18+
1. Shared Map based on shared memory & Shared Map based Ring session store
19+
1. Support Sente, see [this PR](https://github.com/ptaoussanis/sente/pull/160)
20+
1. Support Per-message Compression Extensions (PMCEs) for WebSocket
2021
1. APIs for Embedding Nginx-Clojure into a Standard Clojure/Java/Groovy App
2122
1. Server Side Websocket
2223
1. A build-in Jersey container to support java standard RESTful web services (JAX-RS 2.0)
@@ -48,19 +49,19 @@ Nginx-Clojure has already been published to https://clojars.org/ whose maven rep
4849
</repository>
4950
```
5051

51-
After adding clojars repository, you can reference nginx-clojure 0.4.3 , e.g.
52+
After adding clojars repository, you can reference nginx-clojure 0.4.4 , e.g.
5253

5354
Leiningen (clojure, no need to add clojars repository which is a default repository for Leiningen)
5455
-----------------
5556

5657
```clojure
57-
[nginx-clojure "0.4.3"]
58+
[nginx-clojure "0.4.4"]
5859
```
5960
Gradle (groovy/java)
6061
-----------------
6162

6263
```
63-
compile "nginx-clojure:nginx-clojure:0.4.3"
64+
compile "nginx-clojure:nginx-clojure:0.4.4"
6465
```
6566
Maven
6667
-----------------
@@ -69,7 +70,7 @@ Maven
6970
<dependency>
7071
<groupId>nginx-clojure</groupId>
7172
<artifactId>nginx-clojure</artifactId>
72-
<version>0.4.3</version>
73+
<version>0.4.4</version>
7374
</dependency>
7475
```
7576

nginx-tomcat8/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ in nginx.conf
7070
If `worker_processes` > 1 there will be more than one jvm instances viz. more tomcat instances so to get synchronized session information we can not use the default tomcat session manger.
7171
Instead we may consider to use either of
7272
1. Cookied based Session Store viz. storing all session attribute information into cookies.
73-
1. Shared HashMap among processes in the same machine ,e.g. [Chronicle Map](https://github.com/OpenHFT/Chronicle-Map)
73+
1. Shared HashMap among processes in the same machine ,e.g. nginx-clojure built-in [Shared Map][], OpenHFT [Chronicle Map][]
7474
1. External Session Store, e.g. Redis / MySQL / Memcached Session Store
7575

7676

@@ -121,3 +121,6 @@ location /examples {
121121
## License
122122

123123
Copyright © 2013-2016 Zhang, Yuexiang (xfeep) and released under the BSD 3-Clause license.
124+
125+
[Shared Map]: https://nginx-clojure.github.io/sharedmap.html
126+
[Chronicle Map]: https://github.com/OpenHFT/Chronicle-Map

test/java/nginx/clojure/java/AccessHandlerTestSet4NginxJavaRingHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package nginx.clojure.java;
22

3+
import static nginx.clojure.MiniConstants.DEFAULT_ENCODING;
4+
import static nginx.clojure.MiniConstants.HEADERS;
5+
import static nginx.clojure.java.Constants.PHASE_DONE;
6+
37
import java.io.IOException;
48
import java.io.InputStream;
59
import java.util.Map;
@@ -8,6 +12,7 @@
812

913
import javax.xml.bind.DatatypeConverter;
1014

15+
import org.apache.http.client.config.RequestConfig;
1116
import org.apache.http.client.methods.CloseableHttpResponse;
1217
import org.apache.http.client.methods.HttpGet;
1318
import org.apache.http.impl.client.CloseableHttpClient;
@@ -16,7 +21,6 @@
1621
import nginx.clojure.Configurable;
1722
import nginx.clojure.NginxHttpServerChannel;
1823
import nginx.clojure.SuspendExecution;
19-
import static nginx.clojure.java.Constants.*;
2024

2125
public class AccessHandlerTestSet4NginxJavaRingHandler {
2226

@@ -93,7 +97,10 @@ public static class BasicAuthWithRemoteFetchHandler implements NginxJavaRingHand
9397
public Object[] invoke(Map<String, Object> request) throws SuspendExecution {
9498

9599
CloseableHttpClient httpclient = HttpClients.createDefault();
100+
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(10000).setConnectTimeout(10000)
101+
.setSocketTimeout(10000).build();
96102
HttpGet httpget = new HttpGet("http://www.apache.org/dist/httpcomponents/httpclient/RELEASE_NOTES-4.3.x.txt");
103+
httpget.setConfig(requestConfig);
97104
httpget.setHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36");
98105
CloseableHttpResponse response = null;
99106
try {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package nginx.clojure.java;
2+
3+
import java.io.ByteArrayOutputStream;
4+
import java.io.IOException;
5+
import java.nio.ByteBuffer;
6+
import java.util.Map;
7+
import java.util.UUID;
8+
9+
import nginx.clojure.ChannelCloseAdapter;
10+
import nginx.clojure.NginxClojureRT;
11+
import nginx.clojure.NginxHttpServerChannel;
12+
import nginx.clojure.NginxRequest;
13+
import nginx.clojure.net.NginxClojureAsynSocket;
14+
15+
public class MyBodyReadEventHandler implements NginxJavaRingHandler {
16+
17+
private static class MyContext {
18+
private ByteBuffer readBuffer = ByteBuffer.allocate(100*1024);
19+
private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(5*1024);
20+
21+
}
22+
23+
@Override
24+
public Object[] invoke(Map<String, Object> request) throws IOException {
25+
NginxRequest req = (NginxRequest) request;
26+
NginxHttpServerChannel downstream = req.hijack(true);
27+
downstream.turnOnEventHandler(true, false, true);
28+
UUID uuid = UUID.randomUUID();
29+
String guid = uuid.toString();
30+
MyContext context = new MyContext();
31+
downstream.setContext(context);
32+
downstream.addListener(downstream, new ChannelCloseAdapter<NginxHttpServerChannel>() {
33+
@Override
34+
public void onClose(NginxHttpServerChannel data) throws IOException {
35+
NginxClojureRT.log.info("StreamingWriteHandler closed now!");
36+
}
37+
38+
@Override
39+
public void onRead(long status, NginxHttpServerChannel data) throws IOException {
40+
NginxClojureRT.log.info("Read event called ");
41+
if(status <0) {
42+
NginxClojureRT.log.info("Read status is " + status);
43+
} else {
44+
doRead(data);
45+
}
46+
}
47+
48+
@Override
49+
public void onWrite(long status, NginxHttpServerChannel ch) throws IOException {
50+
if (status < 0) {
51+
NginxClojureRT.log.error("onWrite error %s", NginxClojureAsynSocket.errorCodeToString(status));
52+
ch.close();
53+
}else {
54+
//doWrite(ch);
55+
}
56+
}
57+
});
58+
doRead(downstream);
59+
return null;
60+
}
61+
62+
protected void doRead(NginxHttpServerChannel ch) throws IOException {
63+
NginxClojureRT.log.info("inside doRead method");
64+
MyContext context = (MyContext)ch.getContext();
65+
do {
66+
long c = ch.read(context.readBuffer);
67+
68+
if (c < 0) {
69+
String s = String.format("inside doRead: should have read the whole data , rc=%s, total=%d", c, context.byteArrayOutputStream.size());
70+
NginxClojureRT.log.info(s);
71+
ch.sendResponse(new Object[] {200, null, s});
72+
break;
73+
}if (c == 0) {
74+
break;
75+
} else {
76+
77+
context.readBuffer.flip();
78+
System.out.println(context.readBuffer.remaining());
79+
NginxClojureRT.log.info("inside doRead: draining the buffer to outpustream");
80+
while (context.readBuffer.hasRemaining()) {
81+
context.byteArrayOutputStream.write(context.readBuffer.get());
82+
}
83+
context.readBuffer.clear();
84+
}
85+
86+
}while(true);
87+
88+
}
89+
90+
}

test/nginx-working-dir/conf/nginx-coroutine.conf

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
###you can uncomment next two lines for easy debug
33
daemon off;
44
###Warning: if master_process is off, there will be only one nginx worker running. Only use it for debug propose.
5-
master_process off;
5+
master_process on;
66

77
#user nobody;
88
###you can set worker_processes =1 for easy debug
@@ -227,6 +227,7 @@ http {
227227
handler_type 'java';
228228
handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler';
229229
content_handler_property file testfiles/wcp.html;
230+
send_timeout 10s;
230231
}
231232

232233
location /groovy {
@@ -327,6 +328,12 @@ http {
327328
content_handler_name 'nginx.clojure.java.RewriteHandlerTestSet4NginxJavaRingHandler$SimpleVarHandler';
328329
}
329330

331+
location /javarewrite/ex {
332+
handler_type 'java';
333+
rewrite_handler_name 'nginx.clojure.java.RewriteHandlerTestSet4NginxJavaRingHandler$ExceptionInRewriteHandler';
334+
content_handler_name 'nginx.clojure.java.RewriteHandlerTestSet4NginxJavaRingHandler$SimpleVarHandler';
335+
}
336+
330337
location /javarewrite/hijackpass0 {
331338
handler_type 'java';
332339
rewrite_handler_name 'nginx.clojure.java.RewriteHandlerTestSet4NginxJavaRingHandler$SimpleHijackedRewriteHandler';
@@ -359,7 +366,7 @@ http {
359366
content_handler_name 'nginx.clojure.java.RewriteHandlerTestSet4NginxJavaRingHandler$SimpleVarHandler';
360367
}
361368

362-
location /javarewrite/remote {
369+
location /javarewrite/remote {
363370
handler_type 'java';
364371
rewrite_handler_name 'nginx.clojure.java.RewriteHandlerTestSet4NginxJavaRingHandler$FetchRemoteTextRewriteHandler';
365372
rewrite_handler_property continueToContentHandler true;
@@ -408,7 +415,7 @@ http {
408415
(require \'[clj-http.client :as client])
409416
(fn[req]
410417
(println "enter rewriteWithRemoteRequest")
411-
(set-ngx-var! req "myvar" (:body (client/get "http://www.apache.org/dist/httpcomponents/httpcore/RELEASE_NOTES-4.3.x.txt")))
418+
(set-ngx-var! req "myvar" (:body (client/get "http://www.apache.org/dist/httpcomponents/httpclient/RELEASE_NOTES-4.3.x.txt")))
412419
phrase-done))
413420
';
414421
handler_code '
@@ -676,13 +683,7 @@ http {
676683
location /socket {
677684
handler_type 'java';
678685
handler_name 'nginx.clojure.net.SimpleHandler4TestNginxClojureSocket';
679-
}
680-
681-
location /unixsocket {
682-
content_handler_type 'java';
683-
content_handler_name 'nginx.clojure.net.SimpleHandler4TestNginxClojureSocket';
684-
content_handler_property url 'unix:/home/who/mywss/py/study.py.core/study/py/core/net/uds_socket';
685-
}
686+
}
686687

687688
location /coroutineSocketAndCompojure {
688689
handler_type 'clojure';
@@ -783,20 +784,46 @@ http {
783784
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$MultipleChainHandler';
784785
}
785786

787+
location /javabodyfilter/rmchain {
788+
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$MultipleChainHandler';
789+
body_filter_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$ReadOnlyBodyFilter';
790+
}
791+
792+
location /javabodyfilter/rmedium {
793+
alias testfiles/medium.html;
794+
body_filter_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$ReadOnlyBodyFilter';
795+
}
796+
786797
location /javabodyfilter/utf8mchain {
787798
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$Utf8MultipleChainHandler';
788799
}
789800

790-
location /javabodyfilter/coroutine {
791-
body_filter_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$CoroutineTestBodyFilter';
801+
location /javabodyfilter/hellosf {
802+
body_filter_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$StringFacedUppercaseBodyFilter';
803+
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$Hello';
804+
}
805+
806+
location /javabodyfilter/mchainsf {
807+
body_filter_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$StringFacedUppercaseBodyFilter';
792808
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$MultipleChainHandler';
793809
}
794810

795-
location /javabodyfilter/resume {
796-
content_handler_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$CoroutineResumeHandler';
811+
location /javabodyfilter/utf8mchainsf {
812+
body_filter_name 'nginx.clojure.java.FilterTestSet4NginxJavaBodyFilter$StringFacedUppercaseBodyFilter';
813+
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$Utf8MultipleChainHandler';
797814
}
798815

799-
}
816+
}
817+
818+
location /javaother {
819+
handlers_lazy_init off;
820+
handler_type 'java';
821+
822+
location /javaother/readbodybyevent {
823+
always_read_body off;
824+
content_handler_name nginx.clojure.java.MyBodyReadEventHandler;
825+
}
826+
}
800827

801828
location /cljfilter {
802829
handler_type 'clojure';
@@ -842,8 +869,8 @@ http {
842869
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$Hello';
843870
}
844871
}
845-
846-
location /cljbodyfilter {
872+
873+
location /cljbodyfilter {
847874
handlers_lazy_init off;
848875
handler_type 'clojure';
849876
body_filter_name 'nginx.clojure.filter-handlers-for-test/uppercase-filter';
@@ -881,7 +908,7 @@ http {
881908
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$Utf8MultipleChainHandler';
882909
}
883910

884-
}
911+
}
885912

886913
location /javaaccess {
887914
handler_type 'java';
@@ -947,7 +974,7 @@ http {
947974
alias /home/who/git/tomcat80/webapps/examples/websocket/echo.xhtml;
948975
}
949976
}
950-
977+
951978
location /java-sharedmap {
952979
content_handler_type java;
953980
content_handler_name nginx.clojure.java.SharedMapTestSet4NginxJavaRingHandler;
@@ -969,5 +996,17 @@ http {
969996
}
970997
}
971998

972-
}
973999

1000+
server {
1001+
listen 8181;
1002+
#uncomment this two lines for performance test
1003+
access_log off;
1004+
# error_log /dev/null crit;
1005+
location / {
1006+
handler_type 'java';
1007+
handler_name 'nginx.clojure.java.FileBytesHandler';
1008+
content_handler_property file testfiles/wcp.html;
1009+
}
1010+
1011+
}
1012+
}

test/nginx-working-dir/conf/nginx-plain.conf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,17 @@ http {
819819
content_handler_name 'nginx.clojure.java.GeneralSet4TestNginxJavaRingHandler$Utf8MultipleChainHandler';
820820
}
821821

822-
}
822+
}
823+
824+
location /javaother {
825+
handlers_lazy_init off;
826+
handler_type 'java';
827+
828+
location /javaother/readbodybyevent {
829+
always_read_body off;
830+
content_handler_name nginx.clojure.java.MyBodyReadEventHandler;
831+
}
832+
}
823833

824834
location /cljfilter {
825835
handler_type 'clojure';

0 commit comments

Comments
 (0)