Package net.rim.device.api.io.http

Examples of net.rim.device.api.io.http.HttpHeaders


     * Obtain headers.
     *
     * @return HttpHeaders from the cached item, or null on error.
     */
    public HttpHeaders getHeaders() {
        HttpHeaders headers = null;
        byte[] data = null;

        // Get the code signing key associated with this BlackBerry WebWorks Application
        CodeSigningKey codeSigningKey = CodeSigningKey.get( this );
        // Check Persistent Store for existing data
        PersistentObject cacheItemStore = PersistentStore.getPersistentObject( _storeKey );       

        // If we find an entry in the Persistent store
        if( cacheItemStore != null ) {
            Object cacheItemObj = null;
            try {
              // codeSigningKey is nullable             
                cacheItemObj = cacheItemStore.getContents( codeSigningKey );
            } catch ( ControlledAccessException ignore ) {
                // cacheItemObj remains null
            }
            if( cacheItemObj instanceof ByteVector ) {
                ByteVector cacheItemVector = (ByteVector) cacheItemObj;
                data = cacheItemVector.getArray();
            }
        }
       
        if( data != null ) {
            // Create InputStream
            ByteArrayInputStream dataStream = new ByteArrayInputStream( data );
            CacheManager.receiveLine( dataStream );
            CacheManager.receiveLine( dataStream );
            CacheManager.receiveLine( dataStream );
   
            // Read headers
            headers = new HttpHeaders();
            String line = null;
            while( true ) {
                line = CacheManager.receiveLine( dataStream );
   
                // Headers end with double CRLF
                if( line.length() == 0 ) {
                    break;
                }
   
                try {
                    int indexOfColon = line.indexOf( ':' );
                    if( indexOfColon != -1 ) {
                        headers.setProperty( line.substring( 0, indexOfColon ).trim(),
                                line.substring( indexOfColon + 1 ).trim() );
                    } else {
                        // Drop the header
                    }
                } catch( IndexOutOfBoundsException ignore ) {
View Full Code Here


        // Calculate expires
        long expires = calculateCacheExpires( response );

        // Copy headers
        HttpHeaders headers = copyResponseHeaders( response );

        // Read data
        byte[] data = null;
        InputStream is = null;
        try {
View Full Code Here

        return expires;
    }

    private HttpHeaders copyResponseHeaders( HttpConnection response ) {
        HttpHeaders headers = new HttpHeaders();
        try {
            int index = 0;
            while( response.getHeaderFieldKey( index ) != null ) {
                headers.addProperty( response.getHeaderFieldKey( index ), response.getHeaderField( index ) );
                index++;
            }
        } catch( IOException ioe ) {
        }
View Full Code Here

            o = _cacheTable.get( url );
        }

        if( o instanceof CacheItem ) {
            CacheItem ci = (CacheItem) o;
            HttpHeaders headers = ci.getHeaders();
            byte[] data = ci.getData();
            return new BrowserFieldResponse( url, data, headers );
        }

        return null;
View Full Code Here

        if( encoded == null ) {
            return request;
        }

        String base64AuthCredential = new String( encoded );
        HttpHeaders httpHead = request.getHeaders().cloneHeaders();
        httpHead.setProperty( "Authorization", "Basic " + base64AuthCredential );

        return new BrowserFieldRequest( request.getURL(), request.getPostData(), httpHead );
    }
View Full Code Here

    /**
     * Protected construtor.
     */
    protected WidgetConfigImpl() {
        _customHeaders = new HttpHeaders();
        _notifications = new Hashtable();
        _accessList = new Hashtable();
        _featureTable = new Hashtable();
        _widgetExtensions = new Vector();

View Full Code Here

                                    .getRequestProperty(REFERER);
                }
                break;
            }

            final HttpHeaders requestHeaders = new HttpHeaders();
            requestHeaders.setProperty(REFERER, referrer);
            final PrimaryResourceFetchThread thread =
                    new PrimaryResourceFetchThread(e.getLocation(),
                            requestHeaders, null, event, this);
            thread.start();
            break;
View Full Code Here

     *      boolean)
     */
    public Connection openFilter(final String name, final int mode,
            final boolean timeouts) throws IOException {
        _url = name.substring(2);
        _requestHeaders = new HttpHeaders();
        _responseHeaders = new HttpHeaders();
        _responseHeaders.setProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE,
                "text/html");

        // Attempt to parse for the file name
        final int slashIndex = name.lastIndexOf('/');
View Full Code Here

                }

                break;
            }

            final HttpHeaders requestHeaders = new HttpHeaders();
            requestHeaders.setProperty(REFERER, referrer);
            final PrimaryResourceFetchThread thread =
                    new PrimaryResourceFetchThread(e.getLocation(),
                            requestHeaders, null, event, this);
            thread.start();
            break;
View Full Code Here

    m_comment   = comment;
    m_tags      = tags;
    m_mimeType  = mimeType;
   
    try {         
      HttpConnection httpConn = HttpUtils.makeHttpConnection(urlToRequest, new HttpHeaders(), photo, getCoverageBasedConnectionType(), "POST", this, true);
     
      m_httpStatus = httpConn.getResponseCode();
    
      if (m_httpStatus != 201) {
               System.out.println("Error: " + m_httpStatus);
View Full Code Here

TOP

Related Classes of net.rim.device.api.io.http.HttpHeaders

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.