本文整理了Java中org.apache.hc.core5.http.HttpRequest.getRequestUri()
方法的一些代码示例,展示了HttpRequest.getRequestUri()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getRequestUri()
方法的具体详情如下:
包路径:org.apache.hc.core5.http.HttpRequest
类名称:HttpRequest
方法名:getRequestUri
[英]Returns request URI of this request message. It may be an absolute or relative URI. Applicable to HTTP/1.1 version or earlier.
[中]
代码示例来源:origin: apache/httpcomponents-client
void recordCacheMiss(final HttpHost target, final HttpRequest request) {
cacheMisses.getAndIncrement();
if (log.isTraceEnabled()) {
log.debug("Cache miss [host: " + target + "; uri: " + request.getRequestUri() + "]");
}
}
代码示例来源:origin: apache/httpcomponents-client
void recordCacheHit(final HttpHost target, final HttpRequest request) {
cacheHits.getAndIncrement();
if (log.isTraceEnabled()) {
log.debug("Cache hit [host: " + target + "; uri: " + request.getRequestUri() + "]");
}
}
代码示例来源:origin: apache/httpcomponents-client
void recordCacheFailure(final HttpHost target, final HttpRequest request) {
cacheMisses.getAndIncrement();
if (log.isTraceEnabled()) {
log.debug("Cache failure [host: " + target + "; uri: " + request.getRequestUri() + "]");
}
}
代码示例来源:origin: apache/httpcomponents-client
@Override
public HttpCacheEntry execute(final HttpCacheEntry existing) throws ResourceIOException {
return cacheUpdateHandler.updateParentCacheEntry(request.getRequestUri(), existing, entry, variantKey, variantCacheKey);
}
代码示例来源:origin: apache/httpcomponents-client
@Override
public HttpCacheEntry execute(final HttpCacheEntry existing) throws ResourceIOException {
return cacheUpdateHandler.updateParentCacheEntry(request.getRequestUri(), existing, entry, variantKey, variantCacheKey);
}
代码示例来源:origin: apache/httpcomponents-client
@Override
public HttpCacheEntry execute(final HttpCacheEntry existing) throws ResourceIOException {
return cacheUpdateHandler.updateParentCacheEntry(req.getRequestUri(), existing, entry, variantKey, variantCacheKey);
}
代码示例来源:origin: apache/httpcomponents-client
boolean clientRequestsOurOptions(final HttpRequest request) {
if (!HeaderConstants.OPTIONS_METHOD.equals(request.getMethod())) {
return false;
}
if (!"*".equals(request.getRequestUri())) {
return false;
}
final Header h = request.getFirstHeader(HeaderConstants.MAX_FORWARDS);
if (!"0".equals(h != null ? h.getValue() : null)) {
return false;
}
return true;
}
代码示例来源:origin: apache/httpcomponents-client
@Override
public HttpCacheEntry updateCacheEntry(
final HttpHost host,
final HttpRequest request,
final HttpCacheEntry stale,
final HttpResponse originResponse,
final Date requestSent,
final Date responseReceived) {
if (log.isDebugEnabled()) {
log.debug("Update cache entry: " + host + "; " + new RequestLine(request));
}
final String cacheKey = cacheKeyGenerator.generateKey(host, request);
try {
final HttpCacheEntry updatedEntry = cacheUpdateHandler.updateCacheEntry(
request.getRequestUri(),
stale,
requestSent,
responseReceived,
originResponse);
storeInCache(cacheKey, host, request, updatedEntry);
return updatedEntry;
} catch (final ResourceIOException ex) {
if (log.isWarnEnabled()) {
log.warn("I/O error updating cache entry with key " + cacheKey);
}
return stale;
}
}
代码示例来源:origin: apache/httpcomponents-client
@Override
public HttpCacheEntry updateVariantCacheEntry(
final HttpHost host,
final HttpRequest request,
final HttpResponse originResponse,
final Variant variant,
final Date requestSent,
final Date responseReceived) {
if (log.isDebugEnabled()) {
log.debug("Update variant cache entry: " + host + "; " + new RequestLine(request) + " / " + variant);
}
final HttpCacheEntry entry = variant.getEntry();
final String cacheKey = variant.getCacheKey();
try {
final HttpCacheEntry updatedEntry = cacheUpdateHandler.updateCacheEntry(
request.getRequestUri(),
entry,
requestSent,
responseReceived,
originResponse);
storeEntry(cacheKey, updatedEntry);
return updatedEntry;
} catch (final ResourceIOException ex) {
if (log.isWarnEnabled()) {
log.warn("I/O error updating cache entry with key " + cacheKey);
}
return entry;
}
}
代码示例来源:origin: apache/httpcomponents-client
try {
final HttpCacheEntry updatedEntry = cacheUpdateHandler.updateCacheEntry(
request.getRequestUri(),
stale,
requestSent,
代码示例来源:origin: apache/httpcomponents-client
if (request.getRequestUri().contains("?")) {
if (neverCache1_0ResponsesWithQueryString && from1_0Origin(response)) {
log.debug("Response is not cacheable as it had a query string");
代码示例来源:origin: apache/httpcomponents-client
try {
final HttpCacheEntry updatedEntry = cacheUpdateHandler.updateCacheEntry(
request.getRequestUri(),
entry,
requestSent,
代码示例来源:origin: apache/httpcomponents-client
/**
* Creates a cache entry for the given request, origin response message and response content.
*/
public HttpCacheEntry createtCacheEntry(
final HttpRequest request,
final HttpResponse originResponse,
final ByteArrayBuffer content,
final Date requestSent,
final Date responseReceived) throws ResourceIOException {
return new HttpCacheEntry(
requestSent,
responseReceived,
originResponse.getCode(),
originResponse.getHeaders(),
content != null ? resourceFactory.generate(request.getRequestUri(), content.array(), 0, content.length()) : null);
}
代码示例来源:origin: apache/httpcomponents-client
public static boolean equivalent(final HttpRequest r1, final HttpRequest r2) {
return equivalent(r1.getVersion(), r2.getVersion()) &&
LangUtils.equals(r1.getMethod(), r2.getMethod()) &&
LangUtils.equals(r1.getRequestUri(), r2.getRequestUri()) &&
isEndToEndHeaderSubset(r1, r2);
}
代码示例来源:origin: apache/httpcomponents-client
@Test
public void testBuildUnconditionalRequestUsesRequestUri()
throws Exception {
final String uri = "/theURI";
request = new BasicHttpRequest("GET", uri);
final HttpRequest result = impl.buildUnconditionalRequest(request);
Assert.assertEquals(uri, result.getRequestUri());
}
代码示例来源:origin: apache/httpcomponents-client
@Override
public void handleRequest(
final HttpRequest request,
final EntityDetails entityDetails,
final ResponseChannel responseChannel,
final HttpContext context) throws HttpException, IOException {
final Header h = request.getFirstHeader(HttpHeaders.AUTHORIZATION);
final String challengeResponse = h != null ? authTokenExtractor.extract(h.getValue()) : null;
final URIAuthority authority = request.getAuthority();
final String requestUri = request.getRequestUri();
final boolean authenticated = authenticator.authenticate(authority, requestUri, challengeResponse);
final Header expect = request.getFirstHeader(HttpHeaders.EXPECT);
final boolean expectContinue = expect != null && "100-continue".equalsIgnoreCase(expect.getValue());
if (authenticated) {
if (expectContinue) {
responseChannel.sendInformation(new BasicClassicHttpResponse(HttpStatus.SC_CONTINUE), context);
}
exchangeHandler.handleRequest(request, entityDetails, responseChannel, context);
} else {
final HttpResponse unauthorized = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED);
final String realm = authenticator.getRealm(authority, requestUri);
unauthorized.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"" + realm + "\"");
customizeUnauthorizedResponse(unauthorized);
final AsyncResponseProducer responseProducer = new BasicResponseProducer(
unauthorized,
new BasicAsyncEntityProducer("Unauthorized", ContentType.TEXT_PLAIN));
responseProducerRef.set(responseProducer);
responseProducer.sendResponse(responseChannel, context);
}
}
代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5-cache
void recordCacheMiss(final HttpHost target, final HttpRequest request) {
cacheMisses.getAndIncrement();
if (log.isTraceEnabled()) {
log.debug("Cache miss [host: " + target + "; uri: " + request.getRequestUri() + "]");
}
}
代码示例来源:origin: apache/httpcomponents-client
@Test
public void testBuildConditionalRequestWithETag() {
final String theMethod = "GET";
final String theUri = "/theuri";
final String theETag = "this is my eTag";
final HttpRequest basicRequest = new BasicHttpRequest(theMethod, theUri);
basicRequest.addHeader("Accept-Encoding", "gzip");
final HttpRequest requestWrapper = RequestCopier.INSTANCE.copy(basicRequest);
final Header[] headers = new Header[] {
new BasicHeader("Date", DateUtils.formatDate(new Date())),
new BasicHeader("Last-Modified", DateUtils.formatDate(new Date())),
new BasicHeader("ETag", theETag) };
final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry(headers);
final HttpRequest newRequest = impl.buildConditionalRequest(requestWrapper, cacheEntry);
Assert.assertNotSame(basicRequest, newRequest);
Assert.assertEquals(theMethod, newRequest.getMethod());
Assert.assertEquals(theUri, newRequest.getRequestUri());
Assert.assertEquals(3, newRequest.getHeaders().length);
Assert.assertEquals("Accept-Encoding", newRequest.getHeaders()[0].getName());
Assert.assertEquals("gzip", newRequest.getHeaders()[0].getValue());
Assert.assertEquals("If-None-Match", newRequest.getHeaders()[1].getName());
Assert.assertEquals(theETag, newRequest.getHeaders()[1].getValue());
}
代码示例来源:origin: apache/httpcomponents-client
@Test
public void testBuildConditionalRequestWithLastModified() {
final String theMethod = "GET";
final String theUri = "/theuri";
final String lastModified = "this is my last modified date";
final HttpRequest basicRequest = new BasicHttpRequest(theMethod, theUri);
basicRequest.addHeader("Accept-Encoding", "gzip");
final HttpRequest requestWrapper = RequestCopier.INSTANCE.copy(basicRequest);
final Header[] headers = new Header[] {
new BasicHeader("Date", DateUtils.formatDate(new Date())),
new BasicHeader("Last-Modified", lastModified) };
final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry(headers);
final HttpRequest newRequest = impl.buildConditionalRequest(requestWrapper, cacheEntry);
Assert.assertNotSame(basicRequest, newRequest);
Assert.assertEquals(theMethod, newRequest.getMethod());
Assert.assertEquals(theUri, newRequest.getRequestUri());
Assert.assertEquals(2, newRequest.getHeaders().length);
Assert.assertEquals("Accept-Encoding", newRequest.getHeaders()[0].getName());
Assert.assertEquals("gzip", newRequest.getHeaders()[0].getValue());
Assert.assertEquals("If-Modified-Since", newRequest.getHeaders()[1].getName());
Assert.assertEquals(lastModified, newRequest.getHeaders()[1].getValue());
}
代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5
public RequestLine(final HttpRequest request) {
super();
Args.notNull(request, "Request");
this.method = request.getMethod();
this.uri = request.getRequestUri();
this.protoversion = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
}
内容来源于网络,如有侵权,请联系作者删除!