Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
8831c7b2
Commit
8831c7b2
authored
Feb 27, 2015
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-885: Use NIO for writing the HTTP response.
parent
b1aaa57a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
HttpBindServlet.java
src/java/org/jivesoftware/openfire/http/HttpBindServlet.java
+29
-5
No files found.
src/java/org/jivesoftware/openfire/http/HttpBindServlet.java
View file @
8831c7b2
...
...
@@ -294,11 +294,9 @@ public class HttpBindServlet extends HttpServlet {
if
(
JiveGlobals
.
getBooleanProperty
(
"log.httpbind.enabled"
,
false
))
{
System
.
out
.
println
(
new
Date
()+
": HTTP SENT("
+
session
.
getStreamID
().
getID
()
+
"): "
+
content
);
}
byte
[]
byteContent
=
content
.
getBytes
(
"UTF-8"
);
response
.
setContentLength
(
byteContent
.
length
);
response
.
getOutputStream
().
write
(
byteContent
);
response
.
getOutputStream
().
close
();
context
.
complete
();
final
byte
[]
byteContent
=
content
.
getBytes
(
"UTF-8"
);
response
.
getOutputStream
().
setWriteListener
(
new
WriteListenerImpl
(
context
,
byteContent
)
);
}
private
void
sendError
(
HttpSession
session
,
AsyncContext
context
,
BoshBindingError
bindingError
)
...
...
@@ -435,4 +433,30 @@ public class HttpBindServlet extends HttpServlet {
}
}
}
static
class
WriteListenerImpl
implements
WriteListener
{
private
final
AsyncContext
context
;
private
final
byte
[]
data
;
private
final
String
remoteAddress
;
public
WriteListenerImpl
(
AsyncContext
context
,
byte
[]
data
)
{
this
.
context
=
context
;
this
.
data
=
data
;
this
.
remoteAddress
=
getRemoteAddress
(
context
);
}
@Override
public
void
onWritePossible
()
throws
IOException
{
Log
.
trace
(
"Data can be written to ["
+
remoteAddress
+
"]"
);
context
.
getResponse
().
getOutputStream
().
write
(
data
);
context
.
complete
();
}
@Override
public
void
onError
(
Throwable
throwable
)
{
Log
.
warn
(
"Error writing response data to ["
+
remoteAddress
+
"]"
,
throwable
);
context
.
complete
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment