本文整理了Java中io.sphere.sdk.http.HttpResponse.of()
方法的一些代码示例,展示了HttpResponse.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.of()
方法的具体详情如下:
包路径:io.sphere.sdk.http.HttpResponse
类名称:HttpResponse
方法名:of
暂无
代码示例来源:origin: io.sphere.sdk.jvm/common
public static HttpResponse of(final int status, final String responseBody, final HttpRequest associatedRequest, final HttpHeaders headers) {
return of(status, responseBody, Optional.of(associatedRequest), headers);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
static HttpResponse of(@Nullable final Integer status) {
return of(status, (byte[]) null, null, null);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
static HttpResponse of(@Nullable final Integer status, final String responseBody, final HttpRequest associatedRequest, final HttpHeaders headers) {
return of(status, responseBody.getBytes(StandardCharsets.UTF_8), associatedRequest, headers);
}
代码示例来源:origin: io.sphere.sdk.jvm/sdk-http
static HttpResponse of(@Nullable final Integer status, final String responseBody, final HttpRequest associatedRequest, final HttpHeaders headers) {
return of(status, responseBody.getBytes(StandardCharsets.UTF_8), associatedRequest, headers);
}
代码示例来源:origin: io.sphere.sdk.jvm/common
public static HttpResponse of(final int status, final String responseBody, final Optional<HttpRequest> associatedRequest, final HttpHeaders headers) {
return of(status, Optional.of(responseBody.getBytes(StandardCharsets.UTF_8)), associatedRequest, Optional.of(headers));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Override
protected HttpResponse executeSync(final HttpRequest httpRequest, final int requestId) {
return HttpResponse.of(200, "{\"access_token\": \"vkFuQ6oTwj8_Ye4eiRSsqMeqLYNeQRJi\", \"expires_in\": 1}");
}
};
代码示例来源:origin: io.sphere.sdk.jvm/sdk-http
static HttpResponse of(@Nullable final Integer status, final String responseBody) {
return of(status, responseBody, null, HttpHeaders.of());
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Override
public CompletionStage<HttpResponse> execute(final HttpRequest httpRequest) {
return CompletableFuture.completedFuture(HttpResponse.of(200, response));
}
代码示例来源:origin: io.sphere.sdk.jvm/common
default HttpResponse withoutRequest() {
return HttpResponse.of(getStatusCode(), getResponseBody(), Optional.<HttpRequest>empty(), Optional.of(getHeaders()));
}
}
代码示例来源:origin: io.sphere.jvmsdk/common
public HttpResponse withoutRequest() {
return of(getStatusCode(), getResponseBody());
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Override
public CompletionStage<HttpResponse> execute(final HttpRequest httpRequest) {
final int counterValue = counter.getAndIncrement();
final List<Integer> statusCodes = asList(BAD_GATEWAY_502, SERVICE_UNAVAILABLE_503, GATEWAY_TIMEOUT_504);
final int statusCode = counterValue >= statusCodes.size() ? OK_200 : statusCodes.get(counterValue);
return CompletableFuture.completedFuture(HttpResponse.of(statusCode, "{\"key\": \"foo\"}"));
}
代码示例来源:origin: io.sphere.sdk.jvm/sdk-http
default HttpResponse withoutRequest() {
return HttpResponse.of(getStatusCode(), getResponseBody(), null, getHeaders());
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private HttpResponse convert(final HttpRequest httpRequest, final Response response) {
final byte[] responseBodyAsBytes = getResponseBodyAsBytes(response);
return HttpResponse.of(response.getStatusCode(), responseBodyAsBytes, httpRequest, HttpHeaders.of(response.getHeaders()));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
public static BlockingSphereClient clientForStatusCode(final int statusCode) {
final SphereClient sphereClient = TestDoubleSphereClientFactory
.createHttpTestDouble(intent -> HttpResponse.of(statusCode));
return BlockingSphereClient.of(sphereClient, Duration.ofMillis(100));
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/sdk-http-ahc-2_0
private HttpResponse convert(final HttpRequest httpRequest, final Response response) {
final byte[] responseBodyAsBytes = getResponseBodyAsBytes(response);
final int statusCode = response.getStatusCode();
final HttpHeaders headers = HttpHeaders.ofMapEntryList(response.getHeaders().entries());
return HttpResponse.of(statusCode, responseBodyAsBytes, httpRequest, headers);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private HttpResponse convert(final HttpRequest httpRequest, final Response response) {
final byte[] responseBodyAsBytes = getResponseBodyAsBytes(response);
final int statusCode = response.getStatusCode();
final HttpHeaders headers = HttpHeaders.ofMapEntryList(response.getHeaders().entries());
return HttpResponse.of(statusCode, responseBodyAsBytes, httpRequest, headers);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private HttpResponse convert(final HttpRequest httpRequest, final Response response) {
final byte[] responseBodyAsBytes = getResponseBodyAsBytes(response);
final int statusCode = response.getStatusCode();
final HttpHeaders headers = HttpHeaders.ofMapEntryList(response.getHeaders().entries());
return HttpResponse.of(statusCode, responseBodyAsBytes, httpRequest, headers);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void demoExceptionForCode() {
final int statusCode = 500;
final SphereClient httpTestDouble = TestDoubleSphereClientFactory.createHttpTestDouble(intent -> HttpResponse.of(statusCode));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void noSearchHintNoteOnNormalException() throws Exception {
final SphereClient client = TestDoubleSphereClientFactory.createHttpTestDouble(intent -> HttpResponse.of(500));
assertThatThrownBy(() -> client.execute(CategoryQuery.of()).toCompletableFuture().join())
.hasCauseInstanceOf(SphereException.class)
.matches(e -> ((SphereException) e.getCause()).getAdditionalNotes().stream().allMatch(s -> !s.contains("reindex")));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
public void resultsInA(final Class<? extends Throwable> type) throws Throwable {
thrown.expect(type);
try {
TestDoubleSphereClientFactory.createHttpTestDouble(
request -> HttpResponse.of(responseCode)).execute(CategoryQuery.of()
).toCompletableFuture().join();
} catch (final CompletionException e) {
throw e.getCause();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!