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


Java HttpResponseException类代码示例

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


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

示例1: createHttpResponseException

import org.eclipse.jetty.client.HttpResponseException; //导入依赖的package包/类
private HttpResponseException createHttpResponseException(int statusCode)
{
    HttpResponseException exception = Mockito.mock(HttpResponseException.class);
    Response response = Mockito.mock(Response.class);
    Mockito.when(exception.getResponse()).thenReturn(response);
    Mockito.when(response.getStatus()).thenReturn(statusCode);
    return exception;
}
 
开发者ID:treasure-data,项目名称:embulk-input-marketo,代码行数:9,代码来源:MarketoBaseRestClientTest.java

示例2: extractDataCenter

import org.eclipse.jetty.client.HttpResponseException; //导入依赖的package包/类
private void extractDataCenter(final PluginTask task)
{
    if (task.getAuthMethod() == OAUTH) {
        // Extract data center from meta data URL
        JsonNode response = client.sendRequest("https://login.mailchimp.com/oauth2/metadata", HttpMethod.GET, task);
        MetaDataResponse metaDataResponse;
        try {
            metaDataResponse = mapper.treeToValue(response, MetaDataResponse.class);
            mailchimpEndpoint = MessageFormat.format(mailchimpEndpoint, metaDataResponse.getDc());
        }
        catch (JsonProcessingException e) {
            throw new DataException(e);
        }
    }
    else if (task.getAuthMethod() == API_KEY && task.getApikey().isPresent()) {
        // Authenticate and return data center
        if (!task.getApikey().get().contains("-")) {
            throw new ConfigException("API Key format invalid.");
        }

        String domain = task.getApikey().get().split("-")[1];
        String endpoint = MessageFormat.format(mailchimpEndpoint + "/", domain);
        try {
            client.sendRequest(endpoint, HttpMethod.GET, task);
            mailchimpEndpoint = MessageFormat.format(mailchimpEndpoint, domain);
        }
        catch (HttpResponseException re) {
            throw new ConfigException("Your API key may be invalid, or you've attempted to access the wrong datacenter.");
        }
    }
}
 
开发者ID:treasure-data,项目名称:embulk-output-mailchimp,代码行数:32,代码来源:MailChimpClient.java

示例3: findList

import org.eclipse.jetty.client.HttpResponseException; //导入依赖的package包/类
private void findList(final PluginTask task)
{
    String endpoint = MessageFormat.format(mailchimpEndpoint + "/lists/{0}",
                                           task.getListId());
    try {
        client.sendRequest(endpoint, HttpMethod.GET, task);
    }
    catch (HttpResponseException hre) {
        throw new ConfigException("The `list id` could not be found.");
    }
}
 
开发者ID:treasure-data,项目名称:embulk-output-mailchimp,代码行数:12,代码来源:MailChimpClient.java


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