Android InputStreamEntity - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android InputStreamEntity class.

This code example shows how to use the following methods:
    } 
 
    public PersitingActorTestCase<T> given(InputStream in) {
        httpResponse = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("http", 1, 1),
                200, "OK")); 
        InputStreamEntity entity = new InputStreamEntity(in, -1);
        httpResponse.setEntity(entity);
        return this;
    } 
 
    public PersitingActorTestCase<T> given(String httpResponseBody) {
        httpResponse = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("http", 1, 1),
                200, "OK")); 
        StringEntity entity = null;
        try { 
            entity = new StringEntity(httpResponseBody);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } 
        httpResponse.setEntity(entity);
7
CodeRank
This code example shows how to use the following methods:setContentType
This code example shows how to use the following methods:setChunked, setContentEncoding, setContentType
		return httppost;
	} 
 
	public InputStreamEntity getReqEntity(String xml) throws FileNotFoundException{
		File file = new File(xml);
		InputStreamEntity reqEntity = new InputStreamEntity(
				new FileInputStream(file), -1);
		reqEntity.setContentType("binary/octet-stream");
		reqEntity.setChunked(true);
		reqEntity.setContentEncoding("utf-8");
		return reqEntity;
	} 
	/** 
	 * @param args 
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */ 
	public final static void main(String[] args) throws Exception {
		DefaultHttpClient httpclient = new DefaultHttpClient();
		ClientCustomSSL clientCustomSSL = new ClientCustomSSL();
6
CodeRank
This code example shows how to use the following methods:setContentEncoding, setContentType
            ByteArrayOutputStream out = new ByteArrayOutputStream() ;
            Model model = ModelFactory.createModelForGraph(graph) ;
            model.write(out, Lang.RDFXML.getName()); //model.write(out, WebContent.langNTriples) ;
            byte[] bytes = out.toByteArray() ;
            ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()) ;
            InputStreamEntity reqEntity = new InputStreamEntity(in, bytes.length) ;
            reqEntity.setContentType(Lang.RDFXML.getContentType().getContentType()); //reqEntity.setContentType(WebContent.contentTypeNTriples) ;
            reqEntity.setContentEncoding("UTF-8") ;
            HttpEntity entity = reqEntity ;
            return entity;
            //((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ; 
 
        /* 
        ContentProducer producer = new ContentProducer() { 
            @Override 
            public void writeTo(OutputStream out) throws IOException { 
                RDFDataMgr.write(out, graph, sendLang) ; 
            } 
        } ; 
         
6
CodeRank
This code example shows how to use the following methods:setChunked, setContentType
            HttpPost httppost = new HttpPost("http://localhost:8080" +
                    "/servlets-examples/servlet/RequestInfoExample"); 
 
            File file = new File(args[0]);
 
            InputStreamEntity reqEntity = new InputStreamEntity(
                    new FileInputStream(file), -1);
            reqEntity.setContentType("binary/octet-stream");
            reqEntity.setChunked(true);
            // It may be more appropriate to use FileEntity class in this particular 
            // instance but we are using a more generic InputStreamEntity to demonstrate 
            // the capability to stream out data from any arbitrary source 
            // 
            // FileEntity entity = new FileEntity(file, "binary/octet-stream"); 
 
            httppost.setEntity(reqEntity);
 
            System.out.println("executing request " + httppost.getRequestLine());
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity resEntity = response.getEntity();
6
CodeRank
This code example shows how to use the following methods:
    public void testHandleSuccess(){ 
        String successJSON = "{\"ok\" : true, \"operation_id\" : \"OpID\", " +
                "\"schedule_ids\" : [\"ScheduleID\"]}"; 
        HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(
                new ProtocolVersion("HTTP",1,1), 200, "OK"));
        InputStreamEntity inputStreamEntity = new InputStreamEntity(
                new ByteArrayInputStream(successJSON.getBytes()),
                successJSON.getBytes().length);
        httpResponse.setEntity(inputStreamEntity);
        ScheduleAPIResponseHandler handler = new ScheduleAPIResponseHandler();
 
        try { 
            APIClientResponse<APIScheduleResponse> response =
                    handler.handleResponse(httpResponse);
            assertTrue("Operation ID incorrect", 
                       response.getApiResponse().getOperationId().equals("OpID"));
            assertTrue("HttpResponse is incorrect", 
                       httpResponse.equals(httpResponse));
        } 
        catch (Exception ex){
5
CodeRank
This code example shows how to use the following methods:setChunked, setContentType
            HttpPost httppost = new HttpPost("http://localhost:8080" +
                    "/servlets-examples/servlet/RequestInfoExample"); 
 
            File file = new File(args[0]);
 
            InputStreamEntity reqEntity = new InputStreamEntity(
                    new FileInputStream(file), -1);
            reqEntity.setContentType("binary/octet-stream");
            reqEntity.setChunked(true);
            // It may be more appropriate to use FileEntity class in this particular 
            // instance but we are using a more generic InputStreamEntity to demonstrate 
            // the capability to stream out data from any arbitrary source 
            // 
            // FileEntity entity = new FileEntity(file, "binary/octet-stream"); 
 
            httppost.setEntity(reqEntity);
 
            System.out.println("executing request " + httppost.getRequestLine());
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity resEntity = response.getEntity();
5
CodeRank
This code example shows how to use the following methods:
                "\"error_code\" : 40000," + 
                "\"details\" : {\"error\" : \"Unexpected token '#'\"," + 
                "\"location\" : {\"line\" : 10,\"column\" : 3}}}"; 
        HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(
                new ProtocolVersion("HTTP",1,1), 400, "Unauthorized"));
        InputStreamEntity inputStreamEntity = new InputStreamEntity(
                new ByteArrayInputStream(pushJSON.getBytes()),
                pushJSON.getBytes().length);
        httpResponse.setEntity(inputStreamEntity);
        httpResponse.setHeader(new BasicHeader(CONTENT_TYPE_KEY, UA_JSON_RESPONSE));
 
        /* Test handling */ 
        PushAPIResponseHandler handler = new PushAPIResponseHandler();
        try{ 
            handler.handleResponse(httpResponse);
        } 
        catch (APIRequestException ex){
            System.out.println("Exception " + ex.getMessage());
            APIError error = ex.getError().get();
            System.out.println("Error " + error);
5
CodeRank
This code example shows how to use the following methods:setContentType
        toHttpResponse(stream, response, contentType, -1);
    } 
     
    public static void toHttpResponse(InputStream stream, HttpResponse response, String contentType, long streamLength) throws IOException
    { 
        InputStreamEntity body = new InputStreamEntity(stream, streamLength); 
        body.setContentType(contentType);
        response.setEntity(body);
        response.setStatusCode(HttpStatus.SC_OK);
    } 
     
    public static void fileToHttpResponse(String fullPathFile, HttpResponse response, String contentType, boolean useFileChannels)
    { 
        int status;
        final File file = new File(fullPathFile);
        if (!file.exists())
            status = HttpStatus.SC_NOT_FOUND;
        else if (!file.canRead() || file.isDirectory())
            status = HttpStatus.SC_FORBIDDEN;
        else  
5
CodeRank
This code example shows how to use the following methods:setChunked, setContentType
		boolean saveEncoded = prefs.getBoolean("save_encoded", false);
		if (saveEncoded) {
			filepath = Environment.getExternalStorageDirectory().getPath() + "/recording.flac";
		} 
		uploadStream = new DebugStream(encodedStream, saveEncoded, filepath);
 		InputStreamEntity reqEntity  = new InputStreamEntity(uploadStream, -1);
 
		reqEntity.setContentType(CODEC);
 
		reqEntity.setChunked(true);
 
		return reqEntity;
	} 
 
 
	private StringBuilder inputStreamToString(InputStream is) {
		String line = "";
		StringBuilder total = new StringBuilder();
 
		// Wrap a BufferedReader around the InputStream 
5
CodeRank

Related Android InputStreamEntity Questions & Answers:

See Code Examples for Android InputStreamEntity Methods: