@Test public void requestsAuthorizationWhenBrokenData() throws Exception { final String[] requests = { "GET / HTTP/1.1\nAuthorization: xxx\n\n", "GET / HTTP/1.1\nAuthorization: Basic a1b2c3==\n\n", "GET / HTTP/1.1\nAuthorization: Basic \n\n", }; for (final String http : requests) { try { new SecuredHost( new HostMocker().mock(), HttpRequestMocker.toRequest(http) ).fetch(URI.create("/test.html"), Range.ENTIRE, Version.LATEST); Assert.fail("exception expected, but didn't happen"); } catch (final HttpException ex) { MatcherAssert.assertThat( HttpResponseMocker.toString(ex.response()), Matchers.startsWith( String.format( "HTTP/1.1 %d ", HttpURLConnection.HTTP_BAD_REQUEST ) ) ); } } }
@Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) Resource fetch(@NotNull final URI uri, @NotNull final Range range,
        @NotNull final Version version); @Override boolean isHidden(@NotNull final URI uri); @Override boolean authorized(@NotNull final String user,
        @NotNull final String password); @Override void close(); @Override String syslog(); @Override Stats stats(); }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) Resource fetch(@NotNull final URI uri, @NotNull final Range range,
        @NotNull final Version version); @Override boolean isHidden(@NotNull final URI uri); @Override boolean authorized(@NotNull final String user,
        @NotNull final String password); @Override void close(); @Override String syslog(); @Override Stats stats();  }