本文整理了Java中com.atlassian.sal.api.net.Response.getHeader
方法的一些代码示例,展示了Response.getHeader
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getHeader
方法的具体详情如下:
包路径:com.atlassian.sal.api.net.Response
类名称:Response
方法名:getHeader
暂无
代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core
public String getNextRedirectLocation(final Response response) throws ResponseException
{
final String location = response.getHeader("location");
redirects++;
return location;
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
/**
* @param response response to examine
* @return {@code true}, if the {@code response} contains OAuth authentication challenge
*/
public static boolean hasOAuthChallenge(@Nonnull Response response) {
return response.getHeaders().containsKey(WWW_AUTHENTICATE) &&
response.getHeader(WWW_AUTHENTICATE).trim().startsWith(OAUTH);
}
代码示例来源:origin: com.atlassian.plugins.rest/atlassian-rest-module
public String getHeader(final String s) {
return delegateResponse.getHeader(s);
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core
private boolean hasLocation(final Response response)
{
final String location = response.getHeader("location");
if (isBlank(location)) {
log.warn("HTTP response returned redirect code " + response.getStatusCode() + " but did not provide a location header");
}
return isNotBlank(location);
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
private static ContentType getContentType(Response response) {
try {
String contentTypeValue = response.getHeader(HttpHeaders.CONTENT_TYPE);
if (contentTypeValue != null) {
return ContentType.parse(contentTypeValue);
} else {
return FALLBACK_CONTENT_TYPE;
}
} catch (Exception ignored) {
return FALLBACK_CONTENT_TYPE;
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
private boolean hasLocation(final Response response) {
final String location = response.getHeader("location");
if (isBlank(location)) {
log.warn("HTTP response returned redirect code {} but did not provide a location header",
response.getStatusCode());
}
return isNotBlank(location);
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
public String getNextRedirectLocation(final Response response) {
final String location = response.getHeader("location");
//Make sure the URL is absolute
if (UriBuilder.fromUri(location).build().isAbsolute()) {
url = location;
} else {
URI uri = UriBuilder.fromUri(url).build();
StringBuilder builder = new StringBuilder(uri.getScheme())
.append("://")
.append(uri.getHost());
if (isCustomPort(uri.getScheme(), uri.getPort())) {
builder.append(":").append(uri.getPort());
}
url = builder.append(StringUtils.prependIfMissing(location, "/")).toString();
}
redirects++;
return url;
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-jira3-plugin
public Object handle(Response resp) throws ResponseException
{
try
{
if("ERROR".equals(resp.getHeader("X-Seraph-Trusted-App-Status")))
{
String taError = resp.getHeader("X-Seraph-Trusted-App-Error");
throw new TrustedAppsException(taError);
}
checkForErrors(resp.isSuccessful(), resp.getStatusCode(), resp.getStatusText());
responseHandler.handleJiraResponse(resp.getResponseBodyAsStream(), null);
}
catch (IOException e)
{
throw new ResponseException(e);
}
return null;
}
代码示例来源:origin: com.atlassian.applinks/applinks-common
throw new ResponseException("Server responded with an error");
final String contentTypeHeader = response.getHeader("Content-Type");
if (contentTypeHeader != null && !contentTypeHeader.toLowerCase().startsWith("application/xml")) {
throw new ResponseException("Server sent an invalid response");
代码示例来源:origin: com.atlassian.jira/jira-issue-link-confluence-plugin
private static String getCharset(final Response response)
{
final String DEFAULT = "UTF-8";
final String contentTypeString = response.getHeader("Content-Type");
if (contentTypeString == null) {
return DEFAULT;
}
final ContentType contentType;
try
{
contentType = new ContentType(contentTypeString);
}
catch (final ParseException exception)
{
return DEFAULT;
}
return StringUtils.defaultIfEmpty(contentType.getParameter("charset"), DEFAULT);
}
}
代码示例来源:origin: com.atlassian.jira/jira-issue-link-confluence-plugin
private static String getCharset(final Response response)
{
final String DEFAULT = "UTF-8";
final String contentTypeString = response.getHeader("Content-Type");
if (contentTypeString == null) {
return DEFAULT;
}
final ContentType contentType;
try
{
contentType = new ContentType(contentTypeString);
}
catch (final ParseException exception)
{
return DEFAULT;
}
return StringUtils.defaultIfEmpty(contentType.getParameter("charset"), DEFAULT);
}
}
代码示例来源:origin: com.atlassian.jira/jira-issue-link-remote-jira-plugin
private static String getCharset(final Response response)
{
final String DEFAULT = "UTF-8";
final String contentTypeString = response.getHeader("Content-Type");
if (contentTypeString == null) {
return DEFAULT;
}
final ContentType contentType;
try
{
contentType = new ContentType(contentTypeString);
}
catch (final ParseException exception)
{
return DEFAULT;
}
return StringUtils.defaultIfEmpty(contentType.getParameter("charset"), DEFAULT);
}
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-fisheye-plugin
public Document handle(Response response) throws ResponseException
{
log(response);
alreadyTriedURLs.add(nextTryURL.get());
if (!response.isSuccessful())
{
throw new ResponseException(String.format("Received status code %d (%s)", response.getStatusCode(), response.getStatusText()));
}
// update the redirect info
if (REDIRECT_STATUS_CODES.contains(response.getStatusCode()))
{
String location = response.getHeader("location");
if (location == null)
{
throw new ResponseException(String.format("Received status code %d (%s) but no location was specified", response.getStatusCode(), response.getStatusText()));
}
nextTryURL.set(location);
return null;
}
return extractDocumentFrom(response);
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-fisheye-plugin
public Document handle(Response response) throws ResponseException
{
log(response);
alreadyTriedURLs.add(nextTryURL.get());
if (!response.isSuccessful())
{
throw new ResponseException(String.format("Received status code %d (%s)", response.getStatusCode(), response.getStatusText()));
}
// update the redirect info
if (REDIRECT_STATUS_CODES.contains(response.getStatusCode()))
{
String location = response.getHeader("location");
if (location == null)
{
throw new ResponseException(String.format("Received status code %d (%s) but no location was specified", response.getStatusCode(), response.getStatusText()));
}
nextTryURL.set(location);
return null;
}
return extractDocumentFrom(response);
}
代码示例来源:origin: com.atlassian.jira/jira-issue-link-confluence-plugin
final String location = stripJsessionid(response.getHeader("location"));
if (isNotBlank(location))
代码示例来源:origin: com.atlassian.applinks/applinks-common
public void handle(Response response) throws ResponseException {
// this means the response indicates a redirection.
if (response.getStatusCode() >= 300 && response.getStatusCode() < 400) {
final String location = response.getHeader("Location");
if (location == null) {
throw new ResponseException("manifest not found");
}
LOG.info("Manifest request got redirected to '" + location + "'.");
exception.set(new ManifestGotRedirectedException("manifest got redirected", location));
} else {
checkStatusOk(response);
try {
manifestHolder.set(asManifest(response.getEntity(ManifestEntity.class)));
} catch (Exception ex) {
exception.set(new ResponseContentException(response, ex));
}
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core
public void handle(Response response) throws ResponseException
{
// this means the response indicates a redirection.
if (response.getStatusCode() >= 300 && response.getStatusCode() < 400)
{
final String location = response.getHeader("Location");
if (location == null)
{
throw new ResponseException("manifest not found");
}
LOG.info("Manifest request got redirected to '" + location + "'.");
exception.set(new ManifestGotRedirectedException("manifest got redirected", location));
}
else if (response.isSuccessful())
{
try
{
manifestHolder.set(asManifest(response.getEntity(ManifestEntity.class)));
}
catch (Exception ex)
{
exception.set(ex);
}
}
}
});
代码示例来源:origin: com.atlassian.applinks/applinks-oauth-plugin
final String authHeader = response.getHeader("WWW-Authenticate");
if (authHeader != null && authHeader.startsWith("OAuth")) {
final List<OAuth.Parameter> parameters = OAuthMessage.decodeAuthorization(authHeader);
内容来源于网络,如有侵权,请联系作者删除!