本文整理汇总了Java中org.scribe.model.Response.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getHeader方法的具体用法?Java Response.getHeader怎么用?Java Response.getHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.scribe.model.Response
的用法示例。
在下文中一共展示了Response.getHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TKResponse
import org.scribe.model.Response; //导入方法依赖的package包/类
public TKResponse(Request req) {
Response response = req.send();
String limitUsed = response.getHeader("X-RateLimit-Used");
String limitExpire = response.getHeader("X-RateLimit-Expire");
String limitTotal = response.getHeader("X-RateLimit-Limit");
String limitRemain = response.getHeader("X-RateLimit-Remaining");
if (limitUsed != null) {
rateLimitUsed = Integer.parseInt(limitUsed);
}
if (limitExpire != null) {
rateLimitExpire = Long.parseLong(limitExpire);
}
if (limitTotal != null) {
rateLimitTotal = Integer.parseInt(limitTotal);
}
if (limitRemain != null) {
rateLimitRemaining = Integer.parseInt(limitRemain);
}
this.response = response.getBody();
}
示例2: verifyUpload
import org.scribe.model.Response; //导入方法依赖的package包/类
/**
* Verifies the upload and returns whether it's successful
*
* @param endpoint to verify upload to
* @return the last byte on the server
*/
private static long verifyUpload(String endpoint) {
// Verify the upload
OAuthRequest request = new OAuthRequest(Verb.PUT, endpoint);
request.addHeader("Content-Length", "0");
request.addHeader("Content-Range", "bytes */*");
Response response = request.send();
//printResponse(response, "Verify Upload to " + endpoint); //DEBUG
if (response.getCode() != 308 || !response.isSuccessful()) {
return -1;
}
String range = response.getHeader("Range");
return Long.parseLong(range.substring(range.lastIndexOf("-") + 1)) + 1;
//The + 1 at the end is because Vimeo gives you 0-whatever byte where 0 = the first byte
}
示例3: getRedirectUrl
import org.scribe.model.Response; //导入方法依赖的package包/类
public String getRedirectUrl(String path) {
OAuthRequest request = this.constructGet(path, null);
sign(request);
boolean presetVal = HttpURLConnection.getFollowRedirects();
HttpURLConnection.setFollowRedirects(false);
Response response = request.send();
HttpURLConnection.setFollowRedirects(presetVal);
if (response.getCode() == 301 || response.getCode() == 302) {
return response.getHeader("Location");
} else {
throw new JumblrException(response);
}
}