Java Reference
In-Depth Information
@Override
public void onDataAvailable() throws
IOException {
byte b[] = new byte[3072];
int data = input.read(b);
while (input.isReady() && data != -1) {
outputStream.write(b);
data = input.read(b);
}
}
@Override
public void onAllDataRead() throws
IOException {
System.out.println("onAllDataRead");
}
@Override
public void onError(Throwable t) {
System.out.println("onError : " +
t.getMessage());
}
}
Protocol upgrade processing
Protocol upgrade processing is a mechanism that was introduced in HTTP 1.1 to
provide the possibility of switching from HTTP protocol to another (one that is com-
pletely different). A concrete example of protocol upgrade processing usage is the
migration from HTTP protocol to the WebSocket protocol where the client begins
by sending a request for WebSocket to the server. The client request is sent via
HTTP and if the server accepts the connection request, it will still respond through
HTTP. From this moment, every other communication will be through the estab-
lished WebSocket channel. Support for this mechanism in the Servlet 3.1 Spe-
cification was done by adding the upgrade method to HttpServletRequest
and two new interfaces: javax.servlet.http.HttpUpgradeHandler and
javax.servlet.http.WebConnection .
Search WWH ::




Custom Search