Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit711b3a7

Browse files
author
zhourenjian@gmail.com
committed
Support configure user agent and keep alive headers in Simple RPC
1 parent6e628d1 commit711b3a7

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeRequest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ private static void pipeRequest(final SimplePipeRunnable runnable) {
428428
serialize =null;
429429
}
430430
finalHttpRequestrequest =getRequest();
431+
if (!runnable.supportsKeepAlive()) {
432+
request.setRequestHeader("Connection","close");
433+
}
434+
if (runnableinstanceofISimpleRequestInfo) {
435+
ISimpleRequestInforeqInfo = (ISimpleRequestInfo)runnable;
436+
Stringua =reqInfo.getRemoteUserAgent();
437+
if (ua !=null) {
438+
request.setRequestHeader("User-Agent",ua);
439+
}
440+
}
431441
request.open(method,url,true);
432442
request.registerOnReadyStateChange(newXHRCallbackAdapter() {
433443
publicvoidonLoaded() {

‎sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleRPCRequest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ private static void ajaxRequest(final SimpleRPCRunnable runnable) {
141141
}
142142

143143
finalHttpRequestrequest =getRequest();
144+
if (!runnable.supportsKeepAlive()) {
145+
request.setRequestHeader("Connection","close");
146+
}
147+
if (runnableinstanceofISimpleRequestInfo) {
148+
ISimpleRequestInforeqInfo = (ISimpleRequestInfo)runnable;
149+
Stringua =reqInfo.getRemoteUserAgent();
150+
if (ua !=null) {
151+
request.setRequestHeader("User-Agent",ua);
152+
}
153+
}
144154
request.open(method,url,true);
145155
request.registerOnReadyStateChange(newXHRCallbackAdapter() {
146156
publicvoidonLoaded() {

‎sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleRPCRunnable.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,15 @@ public boolean supportsGZipEncoding() {
7575
returntrue;
7676
}
7777

78+
/**
79+
* Whether supporting HTTP Keep-Alive feature or not.
80+
*
81+
* This method will be called by server side.
82+
*
83+
* @return supported
84+
*/
85+
publicbooleansupportsKeepAlive() {
86+
returntrue;
87+
}
88+
7889
}

‎sources/net.sf.j2s.ajax/ajaxswt/net/sf/j2s/ajax/SimplePipeSWTRequest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ private static void swtPipeRequest(final SimplePipeRunnable runnable) {
174174
serialize =null;
175175
}
176176
finalHttpRequestrequest =getRequest();
177+
if (!runnable.supportsKeepAlive()) {
178+
request.setRequestHeader("Connection","close");
179+
}
180+
if (runnableinstanceofISimpleRequestInfo) {
181+
ISimpleRequestInforeqInfo = (ISimpleRequestInfo)runnable;
182+
Stringua =reqInfo.getRemoteUserAgent();
183+
if (ua !=null) {
184+
request.setRequestHeader("User-Agent",ua);
185+
}
186+
}
177187
request.open(method,url,true);
178188
request.registerOnReadyStateChange(newXHRCallbackSWTAdapter() {
179189
publicvoidswtOnLoaded() {

‎sources/net.sf.j2s.ajax/ajaxswt/net/sf/j2s/ajax/SimpleRPCSWTRequest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ private static void swtAJAXRequest(final SimpleRPCRunnable runnable) {
7272
serialize =null;
7373
}
7474
finalHttpRequestrequest =getRequest();
75+
if (!runnable.supportsKeepAlive()) {
76+
request.setRequestHeader("Connection","close");
77+
}
78+
if (runnableinstanceofISimpleRequestInfo) {
79+
ISimpleRequestInforeqInfo = (ISimpleRequestInfo)runnable;
80+
Stringua =reqInfo.getRemoteUserAgent();
81+
if (ua !=null) {
82+
request.setRequestHeader("User-Agent",ua);
83+
}
84+
}
7585
request.open(method,url,true);
7686
request.registerOnReadyStateChange(newXHRCallbackSWTAdapter() {
7787
publicvoidswtOnLoaded() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp