/** * Only for simpler unit testing. * * @param uri the complete URI string * @param method POST, GET, etc * @param requestData for simulating POST * @return a valid HTTP request */ public static HttpRequest createTestRequest(String uri, Method method, InputStream requestData) { return createTestRequest(uri, method, requestData, null); }
private ExtendedResponse actualOrNullObject(HttpResponse response) { if (response instanceof ExtendedResponse) { return (ExtendedResponse) response; } else { return new NullResponse(Response.Status.OK); } }
@Override public BundleContext bundleContext() { if (restrictedBundleContext == null) { throw newException(); } return restrictedBundleContext; }
public Builder(Handlers config) { serverBindings(config.serverBindings()); clientBindings(config.clientBindings()); }
private int getOverloadReturnCode(HttpRequest request) { if (request.getHeader(Headers.SILENTUPGRADE) != null ) { return 299; } return 429; }
/** * Create a new HTTP request without creating a new JDisc request. This * is for scenarios where another HTTP request handler is invoked * directly without dispatching through JDisc. The parent JDisc request * for the original HttpRequest will be passed on the new HttpRequest * instance's JDisc request, but no properties will be propagated into * the original JDisc request. * * @return a new HttpRequest instance reflecting the given request data * and parameters */ public HttpRequest createDirectRequest() { ensureRequestData(); ensureJdiscParent(); return new HttpRequest(jdiscRequest, requestData, properties); }
@Override public void removeServiceListener(ServiceListener serviceListener) { throw newException(); }
@java.lang.Override public final boolean dispatchGetConfig(ConfigInstance.Producer producer) { if (producer instanceof Producer) { ((Producer)producer).getConfig(this); return true; } return false; }
@Override protected LoggingCompletionHandler createLoggingCompletionHandler(long startTime, long renderStartTime, HttpResponse response, HttpRequest httpRequest, ContentChannelOutputStream rendererWiring) { return new LoggingHandler(startTime, renderStartTime, httpRequest, response, rendererWiring); }
/** * Override this rather than handle(request) to be able to write to the channel before returning from this method. * This default implementation calls handle(request) */ public HttpResponse handle(HttpRequest request, ContentChannel channel) { return handle(request); }
LoggingHandler(long startTime, long renderStartTime, HttpRequest httpRequest, HttpResponse httpResponse, ContentChannelOutputStream rendererWiring) { this.startTime = startTime; this.renderStartTime = renderStartTime; this.commitStartTime = renderStartTime; this.httpRequest = httpRequest; this.httpResponse = httpResponse; this.rendererWiring = rendererWiring; this.extendedResponse = actualOrNullObject(httpResponse); }
/** This must be called before writing to this */ public void setHttpResponse(HttpResponse httpResponse) { if (httpResponse == null && this.httpResponse == null) // the handler in use returned a null response httpResponse = new EmptyResponse(500); this.httpResponse = httpResponse; }
/** * Only for simpler unit testing. * * @param uri the complete URI string * @param method POST, GET, etc * @return a valid HTTP request */ public static HttpRequest createTestRequest(String uri, Method method) { return createTestRequest(uri, method, null); }
@Override public void removeBundleListener(BundleListener bundleListener) { throw newException(); }
@Override public void start() throws BundleException { throw newException(); }
@Override public Bundle getBundle(String localHostname) { throw newException(); }
@Override public Bundle getBundle() { throw newException(); }
@Override public Bundle installBundle(String localHostname, InputStream inputStream) throws BundleException { throw newException(); }
@Override public void addServiceListener(ServiceListener serviceListener) { throw newException(); }
@Override public void removeFrameworkListener(FrameworkListener frameworkListener) { throw newException(); }