Java 类org.apache.http.message.AbstractHttpMessage 实例源码

项目:p2psafety    文件:NetworkManager.java   
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));
    }
}
项目:threatconnect-java    文件:ConnectionUtil.java   
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);
    }
}
项目:logsniffer    文件:HttpPublisher.java   
protected void httpAddons(final AbstractHttpMessage httpMessage,
        final Event event) {
    if (headers != null) {
        for (String headerKey : headers.keySet()) {
            httpMessage.addHeader(headerKey, headers.get(headerKey));
        }
    }
}
项目:p2psafety    文件:NetworkManager.java   
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;
}
项目:fcrepo-webapp-plus    文件:SanityIT.java   
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);
}
项目:codekit-java    文件:RESTClient.java   
/**
 * 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);
        }
    }
}
项目:Onosendai    文件:Hosaka.java   
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);
    }
}
项目:fcrepo4    文件:WebACRecipesIT.java   
/**
 * 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);
}
项目:daq-eclipse    文件:HttpClientTransport.java   
protected void configureMethod(AbstractHttpMessage method) {
    method.setHeader("clientID", clientID);
}
项目:lasso    文件:RestV1Uploader.java   
@Override
protected void setExtraHeaders(AbstractHttpMessage post) {
    post.setHeader("api-secret", secret);
}
项目:lasso    文件:AbstractRestUploader.java   
protected void setExtraHeaders(AbstractHttpMessage httpMessage) {
}
项目:lasso    文件:AbstractRestUploaderTest.java   
@Override
protected void setExtraHeaders(AbstractHttpMessage httpMessage) {
    httpMessage.addHeader("key", "value");
}
项目:stem    文件:BaseHttpClient.java   
protected static void setHeaders(AbstractHttpMessage request) {
    request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
    request.addHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.toString());
}
项目:android-uploader    文件:RestV1Uploader.java   
@Override
protected void setExtraHeaders(AbstractHttpMessage post) {
    post.setHeader("api-secret", secret);
}
项目:android-uploader    文件:AbstractRestUploaderTest.java   
@Override
protected void setExtraHeaders(AbstractHttpMessage httpMessage) {
    httpMessage.addHeader("key", "value");
}
项目:threatconnect-java    文件:ConnectionUtil.java   
static void applyHeaders(Configuration config, AbstractHttpMessage message, String httpMethod, String urlPath)
{
    applyHeaders(config, message, httpMethod, urlPath, null);
}
项目:threatconnect-java    文件:ConnectionUtil.java   
static void applyHeaders(Configuration config, AbstractHttpMessage message, String httpMethod, String urlPath,
    String contentType)
{
    applyHeaders(config, message, httpMethod, urlPath, contentType, config.getContentType());
}
项目:fcrepo-webapp-plus    文件:SanityIT.java   
private static void setAdminAuth(final AbstractHttpMessage method) {
    setAuth(method, "admin1", "password3");
}
项目:android-uploader    文件:AbstractRestUploader.java   
protected void setExtraHeaders(AbstractHttpMessage httpMessage) { }