@Override public Cancellable putEntry(final String key, final HttpCacheEntry entry, final FutureCallback<Boolean> callback) { Args.notEmpty(key, "Key"); Args.notNull(entry, "Cache ehtry"); Args.notNull(callback, "Callback"); try { cacheStorage.putEntry(key, entry); callback.completed(Boolean.TRUE); } catch (final Exception ex) { callback.failed(ex); } return Operations.nonCancellable(); }
final Map<String,String> variantMap) { super(); Args.notNull(requestDate, "Request date"); Args.notNull(responseDate, "Response date"); Args.check(status >= HttpStatus.SC_SUCCESS, "Status code"); Args.notNull(responseHeaders, "Response headers"); this.requestDate = requestDate; this.responseDate = responseDate;
public ExponentialBackOffSchedulingStrategy( final long backOffRate, final TimeValue initialExpiry, final TimeValue maxExpiry) { this.backOffRate = Args.notNegative(backOffRate, "BackOff rate"); this.initialExpiry = Args.notNull(initialExpiry, "Initial expiry"); this.maxExpiry = Args.notNull(maxExpiry, "Max expiry"); }
/** * Adds the filter before the filter with the given name. */ public final AsyncServerBootstrap addFilterBefore(final String existing, final String name, final AsyncFilterHandler filterHandler) { Args.notBlank(existing, "Existing"); Args.notBlank(name, "Name"); Args.notNull(filterHandler, "Filter handler"); filters.add(new FilterEntry<>(FilterEntry.Postion.BEFORE, name, filterHandler, existing)); return this; }
public AuthenticatingAsyncDecorator(final AsyncServerExchangeHandler exchangeHandler, final Authenticator authenticator) { this.exchangeHandler = Args.notNull(exchangeHandler, "Request handler"); this.authenticator = Args.notNull(authenticator, "Authenticator"); this.responseProducerRef = new AtomicReference<>(null); this.authTokenExtractor = new BasicAuthTokenExtractor(); }
private HttpRoute(final HttpHost targetHost, final InetAddress local, final List<HttpHost> proxies, final boolean secure, final TunnelType tunnelled, final LayerType layered) { Args.notNull(targetHost, "Target host"); Args.notNegative(targetHost.getPort(), "Target port"); this.targetHost = targetHost; this.localAddress = local; if (proxies != null && !proxies.isEmpty()) { this.proxyChain = new ArrayList<>(proxies); } else { this.proxyChain = null; } if (tunnelled == TunnelType.TUNNELLED) { Args.check(this.proxyChain != null, "Proxy required if tunnelled"); } this.secure = secure; this.tunnelled = tunnelled != null ? tunnelled : TunnelType.PLAIN; this.layered = layered != null ? layered : LayerType.PLAIN; }
public FrameOutputBuffer(final BasicH2TransportMetrics metrics, final int maxFramePayloadSize) { super(); Args.notNull(metrics, "HTTP2 transport metrcis"); Args.positive(maxFramePayloadSize, "Maximum payload size"); this.metrics = metrics; this.maxFramePayloadSize = maxFramePayloadSize; this.buffer = new byte[FrameConsts.HEAD_LEN + maxFramePayloadSize + FrameConsts.MAX_PADDING + 1]; }
/** * Creates a new instance of {@link ContentType}. * * @param mimeType MIME type. It may not be {@code null} or empty. It may not contain * characters {@code <">, <;>, <,>} reserved by the HTTP specification. * @param charset charset. * @return content type */ public static ContentType create(final String mimeType, final Charset charset) { final String normalizedMimeType = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ROOT); Args.check(valid(normalizedMimeType), "MIME type may not contain reserved characters"); return new ContentType(normalizedMimeType, charset); }
@Override public final HttpHost getHopTarget(final int hop) { Args.notNegative(hop, "Hop index"); final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); HttpHost result = null; if (hop < hopcount-1) { result = this.proxyChain[hop]; } else { result = this.targetHost; } return result; }
/** * Sets the amount of time, in milliseconds, to wait between * adjustments in pool sizes for a given host, to allow * enough time for the adjustments to take effect. Defaults * to 5000L (5 seconds). * @param l must be positive */ public void setCooldownMillis(final long l) { Args.positive(coolDown, "Cool down"); coolDown = l; }
public RawFrame createWindowUpdate(final int streamId, final int increment) { Args.notNegative(streamId, "Stream id"); Args.positive(increment, "Increment"); final ByteBuffer payload = ByteBuffer.allocate(4); payload.putInt(increment); payload.flip(); return new RawFrame(FrameType.WINDOW_UPDATE.getValue(), 0, streamId, payload); }
public LengthDelimitedDecoder( final ReadableByteChannel channel, final SessionInputBuffer buffer, final BasicHttpTransportMetrics metrics, final long contentLength) { super(channel, buffer, metrics); Args.notNegative(contentLength, "Content length"); this.contentLength = contentLength; }
public Builder setMaxFrameSize(final int maxFrameSize) { this.maxFrameSize = Args.checkRange(maxFrameSize, FrameConsts.MIN_FRAME_SIZE, FrameConsts.MAX_FRAME_SIZE, "Invalid max frame size"); return this; }
/** * Update the entry with the new information from the response. Should only be used for * 304 responses. */ public HttpCacheEntry updateCacheEntry( final String requestId, final HttpCacheEntry entry, final Date requestDate, final Date responseDate, final HttpResponse response) throws ResourceIOException { Args.check(response.getCode() == HttpStatus.SC_NOT_MODIFIED, "Response must have 304 status code"); final Header[] mergedHeaders = mergeHeaders(entry, response); Resource resource = null; if (entry.getResource() != null) { resource = resourceFactory.copy(requestId, entry.getResource()); } return new HttpCacheEntry( requestDate, responseDate, entry.getStatus(), mergedHeaders, resource); }
/** * Updates the auth state with a queue of auth options. * * @param authOptions a queue of auth options. May not be null or empty. */ public void setOptions(final Queue<AuthScheme> authOptions) { Args.notEmpty(authOptions, "Queue of auth options"); this.authOptions = authOptions; }
/** * @since 4.4 */ public MultipartEntityBuilder setMimeSubtype(final String subType) { Args.notBlank(subType, "MIME subtype"); this.contentType = ContentType.create("multipart/" + subType); return this; }
/** * Adds the filter before the filter with the given name. */ public final ServerBootstrap addFilterBefore(final String existing, final String name, final HttpFilterHandler filterHandler) { Args.notBlank(existing, "Existing"); Args.notBlank(name, "Name"); Args.notNull(filterHandler, "Filter handler"); filters.add(new FilterEntry<>(FilterEntry.Postion.BEFORE, name, filterHandler, existing)); return this; }
@Override public Resource generate(final String requestId, final byte[] content) throws ResourceIOException { Args.notNull(content, "Content"); return generate(requestId, content, 0, content.length); }
FrameInputBuffer(final BasicH2TransportMetrics metrics, final int bufferLen, final int maxFramePayloadSize) { Args.notNull(metrics, "HTTP2 transport metrcis"); Args.positive(maxFramePayloadSize, "Maximum payload size"); this.metrics = metrics; this.maxFramePayloadSize = maxFramePayloadSize; this.buffer = new byte[bufferLen]; this.dataLen = 0; }
/** * Creates a new instance of {@link ContentType}. * * @param mimeType MIME type. It may not be {@code null} or empty. It may not contain * characters {@code <">, <;>, <,>} reserved by the HTTP specification. * @param charset charset. * @return content type */ public static ContentType create(final String mimeType, final Charset charset) { final String normalizedMimeType = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ROOT); Args.check(valid(normalizedMimeType), "MIME type may not contain reserved characters"); return new ContentType(normalizedMimeType, charset); }