当前位置: 首页>>代码示例>>Java>>正文


Java BasicHttpEntity.setContentType方法代码示例

本文整理汇总了Java中org.apache.http.entity.BasicHttpEntity.setContentType方法的典型用法代码示例。如果您正苦于以下问题:Java BasicHttpEntity.setContentType方法的具体用法?Java BasicHttpEntity.setContentType怎么用?Java BasicHttpEntity.setContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.entity.BasicHttpEntity的用法示例。


在下文中一共展示了BasicHttpEntity.setContentType方法的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: 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

示例3: 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:himanshuagarwal77225,项目名称:BookMySkills,代码行数:26,代码来源:HurlStack.java

示例4: 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

示例5: commit

import org.apache.http.entity.BasicHttpEntity; //导入方法依赖的package包/类
public void commit() throws IOException, HttpException {
    if (this.commited) {
        return;
    }
    this.commited = true;
    
    this.context.setAttribute(ExecutionContext.HTTP_CONNECTION, this.conn);
    this.context.setAttribute(ExecutionContext.HTTP_RESPONSE, this.response);
    
    BasicHttpEntity entity = new BasicHttpEntity();
    entity.setChunked(true);
    entity.setContentType(this.contentType);
    
    this.response.setEntity(entity);
    
    this.httpproc.process(this.response, this.context);
    this.conn.sendResponse(this.response);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:AxisHttpResponseImpl.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: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: entityFromConnection

import org.apache.http.entity.BasicHttpEntity; //导入方法依赖的package包/类
/**
 * Initializes an {@link org.apache.http.HttpEntity} from the given {@link java.net.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:Dreamer206602,项目名称:SimplifyReader2,代码行数:20,代码来源:HurlStack.java

示例14: 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 e) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}
 
开发者ID:joy-inc,项目名称:core-http,代码行数:20,代码来源:HurlStack.java

示例15: 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


注:本文中的org.apache.http.entity.BasicHttpEntity.setContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。