Package com.s3auth.hosts

Examples of com.s3auth.hosts.Resource


    @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);
        }
View Full Code Here


                    )
                    .withHeader(
                        "X-S3auth-Time",
                        Long.toString(System.currentTimeMillis() - start)
                    );
                Resource resource = null;
                try {
                    resource = HttpThread.resource(this.host(request), request);
                    response = response.withHeader(
                        org.apache.http.HttpHeaders.AGE,
                        String.valueOf(
                            TimeUnit.MILLISECONDS.toSeconds(
                                System.currentTimeMillis() - start
                            )
                        )
                    );
                    if (resource.lastModified() != null) {
                        response = response.withHeader(
                            HttpHeaders.LAST_MODIFIED,
                            DateUtils.formatDate(resource.lastModified())
                        );
                    }
                    bytes = response.withBody(resource).send(socket);
                    Logger.info(
                        this, "#run(): %d bytes of %s", bytes, resource
                    );
                } finally {
                    if (resource != null) {
                        resource.close();
                    }
                }
            } else {
                bytes = HttpThread.failure(
                    new HttpException(
View Full Code Here

                    .iterator().next()
            );
        } else {
            version = Version.LATEST;
        }
        Resource resource = host.fetch(
            request.requestUri(), request.range(), version
        );
        if (request.headers().containsKey(HttpHeaders.IF_NONE_MATCH)) {
            final String etag = request.headers()
                .get(HttpHeaders.IF_NONE_MATCH)
                .iterator().next();
            if (etag.equals(resource.etag())) {
                throw new HttpException(HttpURLConnection.HTTP_NOT_MODIFIED);
            }
        }
        if (request.headers().containsKey(HttpHeaders.IF_MODIFIED_SINCE)) {
            final Date since = DateUtils.parseDate(
                request.headers().get(HttpHeaders.IF_MODIFIED_SINCE)
                    .iterator().next()
            );
            if (resource.lastModified().before(since)) {
                throw new HttpException(HttpURLConnection.HTTP_NOT_MODIFIED);
            }
        }
        if (request.headers().containsKey(HttpHeaders.ACCEPT_ENCODING)
            && request.headers().get(HttpHeaders.ACCEPT_ENCODING)
                .contains("gzip")
            && HttpThread.COMPRESSIBLE.contains(resource.contentType())) {
            resource = new GzipResource(resource);
        }
        return resource;
    }
View Full Code Here

    @Test
    public void recognizesCredentialsWithSpecialCharacters() throws Exception {
        final String user = "user";
        final String password = "password%oD\u20ac";
        final Host host = Mockito.mock(Host.class);
        final Resource res = Mockito.mock(Resource.class);
        Mockito.doReturn(res).when(host).fetch(
            Mockito.any(URI.class),
            Mockito.any(Range.class),
            Mockito.any(Version.class)
        );
View Full Code Here

TOP

Related Classes of com.s3auth.hosts.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.