Oracle Fusion Middleware
Java API Reference for Oracle WebLogic Server
12c (12.1.2)

Part Number E27170-01

weblogic.net.http
Interface AsyncResponseCallback

All Known Subinterfaces:
ContextAwareAsyncResponseCallback

public interface AsyncResponseCallback

Callback to be notified when there is response ready to be read. The response can be read using HttpURLConnection methods like getInputStream().

Note that handleResponse() can also be called in exception conditions and the user will encounter the exception while using HttpURLConnection methods to get the response code, read the response bytes etc.



Here is an example:

 public void handleResponse(HttpURLConnection connection) {
 DataInputStream in = null;
 try {
   in = new DataInputStream(connection.getInputStream());
   if (connection.getResponseCode() != 200) {
     throw new IOException("Unexpected error on the server didn't " +
       "receive response code 200");
   }
   byte[] b = new byte[connection.getContentLength()];
   DataIO.readFully(in, b);
 } catch (IOException ioe) {
   // handle exception   
 } finally {
   // IMPORTANT TO CLOSE TO RELEASE CHUNKS
   in.close();
 }
 


Method Summary
 void handleResponse(HttpURLConnection connection)
          This method is called when the response is available to be read from the HttpURLConnection.
 

Method Detail

handleResponse

void handleResponse(HttpURLConnection connection)
This method is called when the response is available to be read from the HttpURLConnection. It is important to note that a complete response might not be available and the read() operation can be block. This callback is invoked when there is some data to be read from the socket.

Parameters:
connection - URLConnection associated with request/response

Copyright 1996, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Oracle Fusion Middleware
Java API Reference for Oracle WebLogic Server
12c (12.1.2)

Part Number E27170-01