本文整理了Java中org.eclipse.jetty.client.api.Request.timeout
方法的一些代码示例,展示了Request.timeout
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.timeout
方法的具体详情如下:
包路径:org.eclipse.jetty.client.api.Request
类名称:Request
方法名:timeout
暂无
代码示例来源:origin: apache/incubator-druid
@Override
protected void sendProxyRequest(
HttpServletRequest clientRequest,
HttpServletResponse proxyResponse,
Request proxyRequest
)
{
proxyRequest.timeout(httpClientConfig.getReadTimeout().getMillis(), TimeUnit.MILLISECONDS);
proxyRequest.idleTimeout(httpClientConfig.getReadTimeout().getMillis(), TimeUnit.MILLISECONDS);
clientRequest.setAttribute(AuthConfig.DRUID_AUTHORIZATION_CHECKED, true); // auth is handled on the destination host
super.sendProxyRequest(clientRequest, proxyResponse, proxyRequest);
}
代码示例来源:origin: apache/incubator-druid
proxyRequest.timeout(httpClientConfig.getReadTimeout().getMillis(), TimeUnit.MILLISECONDS);
proxyRequest.idleTimeout(httpClientConfig.getReadTimeout().getMillis(), TimeUnit.MILLISECONDS);
代码示例来源:origin: apache/incubator-druid
.newRequest(rewriteURI(request, server.getScheme(), server.getHost()))
.method(HttpMethod.DELETE)
.timeout(CANCELLATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
代码示例来源:origin: jersey/jersey
private Request translateRequest(final ClientRequest clientRequest) {
final URI uri = clientRequest.getUri();
final Request request = client.newRequest(uri);
request.method(clientRequest.getMethod());
request.followRedirects(clientRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true));
final Object readTimeout = clientRequest.getConfiguration().getProperties().get(ClientProperties.READ_TIMEOUT);
if (readTimeout != null && readTimeout instanceof Integer && (Integer) readTimeout > 0) {
request.timeout((Integer) readTimeout, TimeUnit.MILLISECONDS);
}
return request;
}
代码示例来源:origin: xuxueli/xxl-job
request.timeout(5000, TimeUnit.MILLISECONDS);
代码示例来源:origin: xuxueli/xxl-job
request.timeout(5000, TimeUnit.MILLISECONDS);
代码示例来源:origin: resteasy/Resteasy
private void configureTimeout(final Request request) {
final Object timeout = request.getAttributes().get(REQUEST_TIMEOUT_MS);
final long timeoutMs;
if (timeout instanceof Duration) {
timeoutMs = ((Duration) timeout).toMillis();
} else if (timeout instanceof Number) {
timeoutMs = ((Number) timeout).intValue();
} else if (timeout != null) {
timeoutMs = Integer.parseInt(timeout.toString());
} else {
timeoutMs = -1;
}
if (timeoutMs > 0) {
request.timeout(timeoutMs, TimeUnit.MILLISECONDS);
}
}
代码示例来源:origin: sixt/ja-micro
@Override
public Request newRequest(String uri) {
Request retval = mock(Request.class);
try {
if (requestsTimeout || (isFirstRequestTimeout && requests.isEmpty())) {
when(retval.send()).thenThrow(new TimeoutException());
} else {
when(retval.send()).thenReturn(httpResponse);
}
if (requestsFail && featureFlag.equals("true")) {
when(httpResponse.getStatus()).thenReturn(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} else if (responseException != null) {
when(httpResponse.getStatus()).thenReturn(responseException.getCategory().getHttpStatus());
} else {
when(httpResponse.getStatus()).thenReturn(HttpServletResponse.SC_OK);
}
} catch (Exception e) {
e.printStackTrace();
}
when(retval.method(anyString())).thenReturn(retval);
when(retval.content(any(ContentProvider.class))).thenReturn(retval);
when(retval.timeout(anyLong(), any(TimeUnit.class))).thenReturn(retval);
requests.add(uri);
return retval;
}
代码示例来源:origin: sixt/ja-micro
@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
when(loadBalancer.getHealthyInstance()).thenReturn(createServiceEndpoint());
when(loadBalancer.getHealthyInstanceExclude(anyListOf(ServiceEndpoint.class)))
.thenReturn(createServiceEndpoint());
when(rpcClient.getRetries()).thenReturn(NUMBER_OF_RETRIES);
when(rpcClient.getTimeout()).thenReturn(0);
httpClientWrapper.setLoadBalancer(loadBalancer);
when(rpcClientMetrics.getMethodTimer(any(), any())).thenReturn(new GoTimer("timer"));
when(tracer.buildSpan(any())).thenReturn(spanBuilder);
when(spanBuilder.start()).thenReturn(span);
when(httpClient.newRequest(any(URI.class))).thenReturn(request);
when(httpClient.newRequest(any(String.class))).thenReturn(request);
when(request.content(any(ContentProvider.class))).thenReturn(request);
when(request.method(anyString())).thenReturn(request);
when(request.timeout(anyLong(), any(TimeUnit.class))).thenReturn(request);
when(request.send()).thenReturn(httpContentResponse);
when(httpContentResponse.getStatus()).thenReturn(100);
dependencyHealthCheck = mock(ServiceDependencyHealthCheck.class);
}
代码示例来源:origin: labsai/EDDI
@Override
public IRequest setTimeout(long timeout, TimeUnit timeUnit) {
request.timeout(timeout, timeUnit);
return this;
}
代码示例来源:origin: org.apache.camel/camel-jetty9
public void setTimeout(long timeout) {
this.request.timeout(timeout, TimeUnit.MILLISECONDS);
}
代码示例来源:origin: openhab/openhab-core
@Override
protected void sendProxyRequest(HttpServletRequest clientRequest, HttpServletResponse proxyResponse,
Request proxyRequest) {
if (service.proxyingVideoWidget(clientRequest)) {
// We disable the timeout for video
proxyRequest.timeout(0, TimeUnit.MILLISECONDS);
// We request the browser to not cache the video
proxyResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
proxyResponse.setHeader("Pragma", "no-cache");
proxyResponse.setHeader("Expires", "0");
}
super.sendProxyRequest(clientRequest, proxyResponse, proxyRequest);
}
代码示例来源:origin: sixt/ja-micro
retval = request.newRequest(httpClient).timeout(client.getTimeout(),
TimeUnit.MILLISECONDS).send();
logger.debug(logMarker, "Http send completed");
代码示例来源:origin: org.apache.druid/druid-server
@Override
protected void sendProxyRequest(
HttpServletRequest clientRequest, HttpServletResponse proxyResponse, Request proxyRequest
)
{
proxyRequest.timeout(httpClientConfig.getReadTimeout().getMillis(), TimeUnit.MILLISECONDS);
proxyRequest.idleTimeout(httpClientConfig.getReadTimeout().getMillis(), TimeUnit.MILLISECONDS);
clientRequest.setAttribute(AuthConfig.DRUID_AUTHORIZATION_CHECKED, true); // auth is handled on the destination host
super.sendProxyRequest(clientRequest, proxyResponse, proxyRequest);
}
代码示例来源:origin: isucon/isucon5-final
private Request createGetRequest(Session session, String path) {
Request req = client.newRequest(config.uri(path))
.method("GET")
.timeout(Config.GET_TIMEOUT, TimeUnit.MILLISECONDS);
session.writeCookie(req);
return req;
}
代码示例来源:origin: isucon/isucon5-qualify
private Request createGetRequest(Session session, String path) {
Request req = client.newRequest(config.uri(path))
.method("GET")
.timeout(Config.GET_TIMEOUT, TimeUnit.MILLISECONDS);
session.writeCookie(req);
return req;
}
代码示例来源:origin: isucon/isucon5-final
private Request createPostRequest(Session session, String path, ContentProvider content) {
Request req = client.newRequest(config.uri(path))
.method("POST")
.timeout(Config.POST_TIMEOUT, TimeUnit.MILLISECONDS)
.content(content)
.header("Content-Length", String.valueOf(content.getLength()));
session.writeCookie(req);
return req;
}
代码示例来源:origin: isucon/isucon5-qualify
private Request createPostRequest(Session session, String path, ContentProvider content) {
Request req = client.newRequest(config.uri(path))
.method("POST")
.timeout(Config.POST_TIMEOUT, TimeUnit.MILLISECONDS)
.content(content)
.header("Content-Length", String.valueOf(content.getLength()));
session.writeCookie(req);
return req;
}
代码示例来源:origin: org.glassfish.jersey.connectors/jersey-jetty-connector
private Request translateRequest(final ClientRequest clientRequest) {
final URI uri = clientRequest.getUri();
final Request request = client.newRequest(uri);
request.method(clientRequest.getMethod());
request.followRedirects(clientRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true));
final Object readTimeout = clientRequest.getConfiguration().getProperties().get(ClientProperties.READ_TIMEOUT);
if (readTimeout != null && readTimeout instanceof Integer && (Integer) readTimeout > 0) {
request.timeout((Integer) readTimeout, TimeUnit.MILLISECONDS);
}
return request;
}
代码示例来源:origin: allegro/hermes
Request buildRequest(Message message, URI uri) {
Request request = client.newRequest(uri)
.method(HttpMethod.POST)
.header(HttpHeader.KEEP_ALIVE.toString(), "true")
.header(MESSAGE_ID.getName(), message.getId())
.header(RETRY_COUNT.getName(), Integer.toString(message.getRetryCounter()))
.header(HttpHeader.CONTENT_TYPE.toString(), contentTypeToMediaType.apply(message.getContentType()))
.timeout(timeout, TimeUnit.MILLISECONDS)
.content(new BytesContentProvider(message.getData()));
message.getSchema().ifPresent(schema -> request.header(SCHEMA_VERSION.getName(), valueOf(schema.getVersion().value())));
authorizationProvider.ifPresent(p -> p.authorizationToken()
.ifPresent(token -> request.header(HttpHeader.AUTHORIZATION.toString(), token)));
metadataAppender.append(request, message);
message.getAdditionalHeaders().forEach(header -> request.header(header.getName(), header.getValue()));
return request;
}
}
内容来源于网络,如有侵权,请联系作者删除!