Search in sources :

Example 6 with HttpConnection

use of javax.microedition.io.HttpConnection in project CodenameOne by codenameone.

the class BlackBerryOS5Implementation method openOutputStream.

/**
 * (non-Javadoc)
 *
 * @see
 * com.codename1.impl.blackberry.BlackBerryImplementation#openOutputStream(java.lang.Object)
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        return super.openOutputStream(connection);
    }
    OutputStream os = ((HttpConnection) connection).openOutputStream();
    // getSoftwareVersion() not available in legacy port,introduced at API 4.3.0
    int majorVersion = DeviceInfo.getSoftwareVersion().charAt(0) - '0';
    // in version 7, BBOS started supporting HTTP 1.1, so facade not required.
    if (majorVersion < 7) {
        os = new BlackBerryOutputStream(os);
    }
    return new BufferedOutputStream(os, ((HttpConnection) connection).getURL());
}
Also used : HttpConnection(javax.microedition.io.HttpConnection) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream) OutputStream(java.io.OutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream)

Example 7 with HttpConnection

use of javax.microedition.io.HttpConnection in project CodenameOne by codenameone.

the class GameCanvasImplementation method getHeaderFieldNames.

/**
 * @inheritDoc
 */
public String[] getHeaderFieldNames(Object connection) throws IOException {
    HttpConnection c = (HttpConnection) connection;
    Vector r = new Vector();
    int i = 0;
    String key = c.getHeaderFieldKey(i);
    while (key != null) {
        if (r.indexOf(key) < 0) {
            r.addElement(key);
        }
        i++;
        key = c.getHeaderFieldKey(i);
    }
    if (r.size() == 0) {
        return null;
    }
    String[] response = new String[r.size()];
    for (int iter = 0; iter < response.length; iter++) {
        response[iter] = (String) r.elementAt(iter);
    }
    return response;
}
Also used : HttpConnection(javax.microedition.io.HttpConnection) Vector(java.util.Vector)

Aggregations

HttpConnection (javax.microedition.io.HttpConnection)7 Vector (java.util.Vector)4 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 BufferedOutputStream (com.codename1.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 Reader (java.io.Reader)1 InputConnection (javax.microedition.io.InputConnection)1 Application (net.rim.device.api.system.Application)1