當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicHttpEntity.setContentEncoding方法代碼示例

本文整理匯總了Java中org.apache.http.entity.BasicHttpEntity.setContentEncoding方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicHttpEntity.setContentEncoding方法的具體用法?Java BasicHttpEntity.setContentEncoding怎麽用?Java BasicHttpEntity.setContentEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.entity.BasicHttpEntity的用法示例。


在下文中一共展示了BasicHttpEntity.setContentEncoding方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * Initializes an {@link HttpEntity} from the given {@link HttpURLConnection}.
 * @param connection
 * @return an HttpEntity populated with data from <code>connection</code>.
 */
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:20,代碼來源:HurlStack.java

示例2: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * Initializes an {@link HttpEntity} from the given {@link HttpURLConnection}.
 *
 * @return an HttpEntity populated with data from <code>connection</code>.
 */
/*
 *  通過一個 HttpURLConnection 獲取其對應的 HttpEntity ( 這裏就 HttpEntity 而言,耦合了 Apache )
 */
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    // 設置 HttpEntity 的內容
    entity.setContent(inputStream);
    // 設置 HttpEntity 的長度
    entity.setContentLength(connection.getContentLength());
    // 設置 HttpEntity 的編碼
    entity.setContentEncoding(connection.getContentEncoding());
    // 設置 HttpEntity Content-Type
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:CaMnter,項目名稱:SaveVolley,代碼行數:27,代碼來源:HurlStack.java

示例3: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * 獲取響應報文實體
 * 
 * @return
 * @throws IOException
 */
private HttpEntity entityFromConnection() throws IOException {
	BasicHttpEntity entity = new BasicHttpEntity();
	InputStream inputStream;
	try {
		inputStream = connection.getInputStream();
	} catch (IOException ioe) {
		inputStream = connection.getErrorStream();
	}
	if (GZIP.equals(getResponseheader(ResponseHeader.HEADER_CONTENT_ENCODING))) {
		entity.setContent(new GZIPInputStream(inputStream));
	} else {
		entity.setContent(inputStream);
	}
	entity.setContentLength(connection.getContentLength());
	entity.setContentEncoding(connection.getContentEncoding());
	entity.setContentType(connection.getContentType());
	return entity;
}
 
開發者ID:Leaking,項目名稱:WeGit,代碼行數:25,代碼來源:HttpKnife.java

示例4: convertEntityNewToOld

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private org.apache.http.HttpEntity convertEntityNewToOld(HttpEntity ent) throws IllegalStateException, IOException
{

	BasicHttpEntity ret = new BasicHttpEntity();
	if (ent != null)
	{
		ret.setContent(ent.getContent());
		ret.setContentLength(ent.getContentLength());
		Header h;
		h = ent.getContentEncoding();
		if (h != null)
		{
			ret.setContentEncoding(convertheaderNewToOld(h));
		}
		h = ent.getContentType();
		if (h != null)
		{
			ret.setContentType(convertheaderNewToOld(h));
		}
	}

	return ret;
}
 
開發者ID:himanshuagarwal77225,項目名稱:BookMySkills,代碼行數:24,代碼來源:ExtHttpClientStack.java

示例5: getEntityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private HttpEntity getEntityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;

    try {
        inputStream = connection.getInputStream();
    } catch (IOException e) {
        inputStream = connection.getErrorStream();
    }

    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:ppdai,項目名稱:BaijiClient4Android,代碼行數:17,代碼來源:HurlStack.java

示例6: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * Initializes an {@link HttpEntity} from the given
 * {@link HttpURLConnection}.
 * 
 * @param connection
 * @return an HttpEntity populated with data from <code>connection</code>.
 */
private static HttpEntity entityFromConnection(HttpURLConnection connection) {

    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:barterli,項目名稱:barterli_android,代碼行數:23,代碼來源:HurlStack.java

示例7: convertEntityNewToOld

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private org.apache.http.HttpEntity convertEntityNewToOld(HttpEntity ent) 
        throws IllegalStateException, IOException {
    
    BasicHttpEntity ret = new BasicHttpEntity();
    if (ent != null) {
        ret.setContent(ent.getContent());
        ret.setContentLength(ent.getContentLength());
        Header h;
        h = ent.getContentEncoding();
        if (h != null) {
            ret.setContentEncoding(convertheaderNewToOld(h));
        }
        h = ent.getContentType();
        if (h != null) {
            ret.setContentType(convertheaderNewToOld(h));
        }
    }

    return ret;
}
 
開發者ID:WassimBenltaief,項目名稱:laposte-android,代碼行數:21,代碼來源:ExtHttpClientStack.java

示例8: testAddExistedTask

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
@Test
public void testAddExistedTask() throws Exception {
	// create 3 tasks in project
	TaskObject task1 = new TaskObject(mProject.getId());
	task1.setName("TASK_NAME1").save();
	
	TaskObject task2 = new TaskObject(mProject.getId());
	task2.setName("TASK_NAME2").save();
	
	TaskObject task3 = new TaskObject(mProject.getId());
	task3.setName("TASK_NAME3").save();
	
	// initial request data,add task#1 & #3 to story#1
	StoryObject story = mASTS.getStories().get(0);
	String taskIdJsonString = String.format("[%s, %s]", task1.getId(), task2.getId());
	String URL = String.format(API_URL, mProjectName, story.getId() + "/add-existed-task", mUsername, mPassword);
	BasicHttpEntity entity = new BasicHttpEntity();
	entity.setContent(new ByteArrayInputStream(taskIdJsonString.getBytes()));
	entity.setContentEncoding("utf-8");
	HttpPost httpPost = new HttpPost(URL);
	httpPost.setEntity(entity);
	mHttpClient.execute(httpPost);
	
	story.reload();
	assertEquals(2, story.getTasks().size());
}
 
開發者ID:ezScrum,項目名稱:ezScrum,代碼行數:27,代碼來源:StoryWebServiceControllerTest.java

示例9: entityFromOkHttpResponse

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = r.body();

    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(r.header("Content-Encoding"));

    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }
    return entity;
}
 
開發者ID:wangzhaosheng,項目名稱:publicProject,代碼行數:14,代碼來源:OkHttpStack.java

示例10: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * Initializes an {@link HttpEntity} from the given {@link HttpURLConnection}.
 *
 * @param connection
 * @return an HttpEntity populated with data from <code>connection</code>.
 */
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:21,代碼來源:BaseStack.java

示例11: doDeserialize

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * Creates a {@link BasicHttpEntity} based on properties of the given
 * message. The content of the entity is created by wrapping
 * {@link SessionInputBuffer} with a content decoder depending on the
 * transfer mechanism used by the message.
 * <p>
 * This method is called by the public
 * {@link #deserialize(SessionInputBuffer, HttpMessage)}.
 *
 * @param inbuffer the session input buffer.
 * @param message the message.
 * @return HTTP entity.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
protected BasicHttpEntity doDeserialize(
        final SessionInputBuffer inbuffer,
        final HttpMessage message) throws HttpException, IOException {
    BasicHttpEntity entity = new BasicHttpEntity();

    long len = this.lenStrategy.determineLength(message);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(new ChunkedInputStream(inbuffer));
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(new IdentityInputStream(inbuffer));
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(new ContentLengthInputStream(inbuffer, len));
    }

    Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:46,代碼來源:EntityDeserializer.java

示例12: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:DLKanth,項目名稱:Stetho-Volley,代碼行數:15,代碼來源:StethoVolleyStack.java

示例13: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    InputStream inputStream;
    BasicHttpEntity entity = new BasicHttpEntity();
    try {
        inputStream = connection.getInputStream();
    } catch (IOException e) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength((long) connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:15,代碼來源:MyHttpStack.java

示例14: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
/**
 * Initializes an {@link org.apache.http.HttpEntity} from the given {@link HttpURLConnection}.
 * @param connection
 * @return an HttpEntity populated with data from <code>connection</code>.
 */
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
開發者ID:TeskaLabs,項目名稱:SeaCat-Volley-Android,代碼行數:20,代碼來源:SeaCatStack.java

示例15: getEntity

import org.apache.http.entity.BasicHttpEntity; //導入方法依賴的package包/類
private static HttpEntity getEntity(Response response) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = response.body();
    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(response.header("Content-Encoding"));
    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }
    return entity;
}
 
開發者ID:PatrickShaw,項目名稱:SpotlessGHack-Intellibins-Android,代碼行數:12,代碼來源:OkHttpStack.java


注:本文中的org.apache.http.entity.BasicHttpEntity.setContentEncoding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。