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


Java AbstractHttpMessage类代码示例

本文整理汇总了Java中org.apache.http.message.AbstractHttpMessage的典型用法代码示例。如果您正苦于以下问题:Java AbstractHttpMessage类的具体用法?Java AbstractHttpMessage怎么用?Java AbstractHttpMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractHttpMessage类属于org.apache.http.message包,在下文中一共展示了AbstractHttpMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addUserAgentHeader

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
public static void addUserAgentHeader(Context context, AbstractHttpMessage request) {
    String systemUserAgent = System.getProperty("http.agent");
    String customUserAgent = "";
    try {
        customUserAgent = new StringBuilder().append("p2psafety/")
                // add app version
                .append(context.getPackageManager()
                        .getPackageInfo(context.getPackageName(), 0).versionName).append(" ")
                        // split davlik machine version
                .append(systemUserAgent.substring(systemUserAgent.indexOf('(', 0),
                        systemUserAgent.length())).toString();
        request.addHeader(new BasicHeader("User-Agent", customUserAgent));
        Log.i("getUserAgent", customUserAgent);
    } catch (PackageManager.NameNotFoundException e) {
        request.addHeader(new BasicHeader("User-Agent", systemUserAgent));
    }
}
 
开发者ID:42cc,项目名称:p2psafety,代码行数:18,代码来源:NetworkManager.java

示例2: applyHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
static void applyHeaders(Configuration config, AbstractHttpMessage message, String httpMethod, String urlPath,
	String contentType, String acceptType)
{
	if (config.getTcToken() != null)
	{
		message.addHeader("authorization", "TC-Token " + config.getTcToken());
	}
	else
	{
		Long ts = System.currentTimeMillis() / 1000L;
		String sig = getSignature(ts, httpMethod, urlPath, null);
		String hmacSig = getHmacSha256Signature(sig, config.getTcApiUserSecretKey());
		String auth = getAuthorizationText(config, hmacSig);
		
		message.addHeader("timestamp", "" + ts);
		message.addHeader("authorization", auth);
	}
	
	message.addHeader("Accept", acceptType);
	if (contentType != null)
	{
		message.addHeader("Content-Type", contentType);
	}
}
 
开发者ID:ThreatConnect-Inc,项目名称:threatconnect-java,代码行数:25,代码来源:ConnectionUtil.java

示例3: httpAddons

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
protected void httpAddons(final AbstractHttpMessage httpMessage,
		final Event event) {
	if (headers != null) {
		for (String headerKey : headers.keySet()) {
			httpMessage.addHeader(headerKey, headers.get(headerKey));
		}
	}
}
 
开发者ID:logsniffer,项目名称:logsniffer,代码行数:9,代码来源:HttpPublisher.java

示例4: addAuthHeader

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
private static AbstractHttpMessage addAuthHeader(Context context, AbstractHttpMessage request) {
    request.addHeader(new BasicHeader("Authorization", new StringBuilder().append("ApiKey ")
            .append(Prefs.getApiUsername(context)).append(":")
            .append(Prefs.getApiKey(context)).toString()));
    Log.i("addAuthHeader", Prefs.getApiUsername(context) + ":" + Prefs.getApiKey(context));
    return request;
}
 
开发者ID:42cc,项目名称:p2psafety,代码行数:8,代码来源:NetworkManager.java

示例5: setAuth

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
private static void setAuth(final AbstractHttpMessage method, final String username, final String password) {
    final String creds = username + ":" + password;
    // in test configuration we don't need real passwords
    final String encCreds =
            new String(Base64.encodeBase64(creds.getBytes()));
    final String basic = "Basic " + encCreds;
    method.setHeader("Authorization", basic);
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-webapp-plus,代码行数:9,代码来源:SanityIT.java

示例6: addInternalHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
/**
 * Sets headers to the http message.
 *
 * @param httpMsg http message to set headers for
 */
private void addInternalHeaders(AbstractHttpMessage httpMsg) {
    if (headers.isEmpty()) {
        return;
    }

    final Set<String> keySet = headers.keySet();
    for (final String key : keySet) {
        final List<String> values = headers.get(key);
        for (final String value : values) {
            httpMsg.addHeader(key, value);
        }
    }
}
 
开发者ID:attdevsupport,项目名称:codekit-java,代码行数:19,代码来源:RESTClient.java

示例7: addAuth

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
private void addAuth (final AbstractHttpMessage req) {
	try {
		req.setHeader("Authorization", "Basic " + Base64.encodeToString(
				(this.account.getAccessToken() + ":" + this.account.getAccessSecret()).getBytes("UTF-8"),
				Base64.NO_WRAP));
	}
	catch (final UnsupportedEncodingException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:haku,项目名称:Onosendai,代码行数:11,代码来源:Hosaka.java

示例8: setAuth

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
/**
 * Convenience method for applying credentials to a request
 *
 * @param method the request to add the credentials to
 * @param username the username to add
 */
private static void setAuth(final AbstractHttpMessage method, final String username) {
    final String creds = username + ":password";
    final String encCreds = new String(Base64.encodeBase64(creds.getBytes()));
    final String basic = "Basic " + encCreds;
    method.setHeader("Authorization", basic);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:13,代码来源:WebACRecipesIT.java

示例9: configureMethod

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
protected void configureMethod(AbstractHttpMessage method) {
    method.setHeader("clientID", clientID);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:4,代码来源:HttpClientTransport.java

示例10: setExtraHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
@Override
protected void setExtraHeaders(AbstractHttpMessage post) {
    post.setHeader("api-secret", secret);
}
 
开发者ID:nightscout,项目名称:lasso,代码行数:5,代码来源:RestV1Uploader.java

示例11: setExtraHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
protected void setExtraHeaders(AbstractHttpMessage httpMessage) {
}
 
开发者ID:nightscout,项目名称:lasso,代码行数:3,代码来源:AbstractRestUploader.java

示例12: setExtraHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
@Override
protected void setExtraHeaders(AbstractHttpMessage httpMessage) {
    httpMessage.addHeader("key", "value");
}
 
开发者ID:nightscout,项目名称:lasso,代码行数:5,代码来源:AbstractRestUploaderTest.java

示例13: setHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
protected static void setHeaders(AbstractHttpMessage request) {
    request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
    request.addHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.toString());
}
 
开发者ID:odiszapc,项目名称:stem,代码行数:5,代码来源:BaseHttpClient.java

示例14: setAdminAuth

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
private static void setAdminAuth(final AbstractHttpMessage method) {
    setAuth(method, "admin1", "password3");
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-webapp-plus,代码行数:4,代码来源:SanityIT.java

示例15: setExtraHeaders

import org.apache.http.message.AbstractHttpMessage; //导入依赖的package包/类
protected void setExtraHeaders(AbstractHttpMessage httpMessage) { } 
开发者ID:nightscout,项目名称:android-uploader,代码行数:2,代码来源:AbstractRestUploader.java


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