本文整理匯總了Java中com.ning.http.client.RequestBuilderBase類的典型用法代碼示例。如果您正苦於以下問題:Java RequestBuilderBase類的具體用法?Java RequestBuilderBase怎麽用?Java RequestBuilderBase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RequestBuilderBase類屬於com.ning.http.client包,在下文中一共展示了RequestBuilderBase類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateAndAddSignature
import com.ning.http.client.RequestBuilderBase; //導入依賴的package包/類
@Override
public void calculateAndAddSignature(Request request, RequestBuilderBase<?> builder) {
long now = Long.parseLong(request.getHeaders().getFirstValue("X-Buttercoin-Date"));
StringBuilder signature = new StringBuilder();
signature.append(now);
signature.append(request.getUrl());
if (request.getStringData() != null && request.getStringData().length() > 0)
signature.append(request.getStringData());
builder.addHeader("X-Buttercoin-Access-Key", apiKey);
Mac mac;
try {
mac = (Mac) SHARED_MAC.clone();
mac.init(signingKey);
} catch (CloneNotSupportedException | InvalidKeyException e) {
throw new RuntimeException(e);
}
builder.addHeader("X-Buttercoin-Signature", Base64.encode(mac.doFinal(Base64.encode((signature.toString()).getBytes()).getBytes())));
}
示例2: calculateSignature
import com.ning.http.client.RequestBuilderBase; //導入依賴的package包/類
public static void calculateSignature(Signer signer, Request request, RequestBuilderBase<?> requestBuilder) {
RequestContent.Builder sigBuilder = new RequestContent.Builder();
sigBuilder.setRequestTarget(request.getMethod(), getRequestPath(request));
for (FluentCaseInsensitiveStringsMap.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
for (String value : entry.getValue()) {
sigBuilder.addHeader(entry.getKey(), value);
}
}
if (sigBuilder.build().getDate() == null) {
sigBuilder.addDateNow();
requestBuilder.addHeader(Constants.HEADER_DATE, sigBuilder.build().getDate());
}
Authorization authz = signer.sign(sigBuilder.build());
if (authz != null) {
requestBuilder.setHeader(Constants.AUTHORIZATION, authz.getHeaderValue());
}
}
示例3: calculateAndAddSignature
import com.ning.http.client.RequestBuilderBase; //導入依賴的package包/類
@Override
public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) { }