/** * Returns the last modified time of this file. * <p> * This implementation throws an exception. */ @Override protected long doGetLastModifiedTime() throws Exception { final Header header = method.getResponseHeader("last-modified"); if (header == null) { throw new FileSystemException("vfs.provider.http/last-modified.error", getName()); } return DateUtil.parseDate(header.getValue()).getTime(); }
/** * Returns the last modified time of this file. * <p> * This implementation throws an exception. */ @Override protected long doGetLastModifiedTime() throws Exception { final Header header = method.getResponseHeader("last-modified"); FileSystemException.requireNonNull(header, "vfs.provider.http/last-modified.error", getName()); return DateUtil.parseDate(header.getValue()).getTime(); }
/** * Returns the last modified time of this file. * <p> * This implementation throws an exception. */ @Override protected long doGetLastModifiedTime() throws Exception { final Header header = method.getResponseHeader("last-modified"); if (header == null) { throw new FileSystemException("vfs.provider.http/last-modified.error", getName()); } return DateUtil.parseDate(header.getValue()).getTime(); }
/** * Determines the type of this file. Must not return null. The return value of this method is cached, so the * implementation can be expensive. */ @Override protected FileType doGetType() throws Exception { // Use the HEAD method to probe the file. final int status = this.getHeadMethod().getStatusCode(); if (status == HttpURLConnection.HTTP_OK || status == HttpURLConnection.HTTP_BAD_METHOD /* method is bad, but resource exist */) { return FileType.FILE; } else if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) { return FileType.IMAGINARY; } else { throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status)); } }
/** * Determines the type of this file. Must not return null. The return value of this method is cached, so the * implementation can be expensive. */ @Override protected FileType doGetType() throws Exception { // Use the HEAD method to probe the file. final int status = this.getHeadMethod().getStatusCode(); if (status == HttpURLConnection.HTTP_OK || status == HttpURLConnection.HTTP_BAD_METHOD /* method is bad, but resource exist */) { return FileType.FILE; } else if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) { return FileType.IMAGINARY; } else { throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status)); } }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. * <p> * It is guaranteed that there are no open output streams for this file when this method is called. * <p> * The returned stream does not have to be buffered. */ @Override protected InputStream doGetInputStream() throws Exception { final GetMethod getMethod = new GetMethod(); setupMethod(getMethod); final int status = getAbstractFileSystem().getClient().executeMethod(getMethod); if (status == HttpURLConnection.HTTP_NOT_FOUND) { throw new FileNotFoundException(getName()); } if (status != HttpURLConnection.HTTP_OK) { throw new FileSystemException("vfs.provider.http/get.error", getName(), Integer.valueOf(status)); } return new HttpInputStream(getMethod); }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. * <p> * It is guaranteed that there are no open output streams for this file when this method is called. * <p> * The returned stream does not have to be buffered. */ @Override protected InputStream doGetInputStream() throws Exception { final GetMethod getMethod = new GetMethod(); setupMethod(getMethod); final int status = getAbstractFileSystem().getClient().executeMethod(getMethod); if (status == HttpURLConnection.HTTP_NOT_FOUND) { throw new FileNotFoundException(getName()); } if (status != HttpURLConnection.HTTP_OK) { throw new FileSystemException("vfs.provider.http/get.error", getName(), Integer.valueOf(status)); } return new HttpInputStream(getMethod); }
/** * Determines the type of this file. Must not return null. The return value of this method is cached, so the * implementation can be expensive. */ @Override protected FileType doGetType() throws Exception { // Use the HEAD method to probe the file. final int status = this.getHeadMethod().getStatusCode(); if (status == HttpURLConnection.HTTP_OK || status == HttpURLConnection.HTTP_BAD_METHOD /* method is bad, but resource exist */) { return FileType.FILE; } else if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) { return FileType.IMAGINARY; } else { throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status)); } }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. * <p> * It is guaranteed that there are no open output streams for this file when this method is called. * <p> * The returned stream does not have to be buffered. */ @Override protected InputStream doGetInputStream() throws Exception { final GetMethod getMethod = new GetMethod(); setupMethod(getMethod); final int status = getAbstractFileSystem().getClient().executeMethod(getMethod); if (status == HttpURLConnection.HTTP_NOT_FOUND) { throw new FileNotFoundException(getName()); } if (status != HttpURLConnection.HTTP_OK) { throw new FileSystemException("vfs.provider.http/get.error", getName(), Integer.valueOf(status)); } return new HttpInputStream(getMethod); }
final int status = fileSystem.getClient().executeMethod(getMethod); if (status != HttpURLConnection.HTTP_PARTIAL && status != HttpURLConnection.HTTP_OK) { throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(), Long.valueOf(filePointer), Integer.valueOf(status)); final long skipped = mis.skip(filePointer); if (skipped != filePointer) { throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(), Long.valueOf(filePointer), Integer.valueOf(status));
final int status = fileSystem.getClient().executeMethod(getMethod); if (status != HttpURLConnection.HTTP_PARTIAL && status != HttpURLConnection.HTTP_OK) { throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(), Long.valueOf(filePointer), Integer.valueOf(status)); final long skipped = mis.skip(filePointer); if (skipped != filePointer) { throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(), Long.valueOf(filePointer), Integer.valueOf(status));
final int status = fileSystem.getClient().executeMethod(getMethod); if (status != HttpURLConnection.HTTP_PARTIAL && status != HttpURLConnection.HTTP_OK) { throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(), Long.valueOf(filePointer), Integer.valueOf(status)); final long skipped = mis.skip(filePointer); if (skipped != filePointer) { throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(), Long.valueOf(filePointer), Integer.valueOf(status));
/** * Prepares a HttpMethod object. * * @param method The object which gets prepared to access the file object. * @throws FileSystemException if an error occurs. * @throws URIException if path cannot be represented. * @since 2.0 (was package) */ protected void setupMethod(final HttpMethod method) throws FileSystemException, URIException { final String pathEncoded = ((URLFileName) getName()).getPathQueryEncoded(this.getUrlCharset()); method.setPath(pathEncoded); method.setFollowRedirects(this.getFollowRedirect()); method.setRequestHeader("User-Agent", this.getUserAgent()); }
/** * Prepares a HttpMethod object. * * @param method The object which gets prepared to access the file object. * @throws FileSystemException if an error occurs. * @throws URIException if path cannot be represented. * @since 2.0 (was package) */ protected void setupMethod(final HttpMethod method) throws FileSystemException, URIException { final String pathEncoded = ((URLFileName) getName()).getPathQueryEncoded(this.getUrlCharset()); method.setPath(pathEncoded); method.setFollowRedirects(this.getFollowRedirect()); method.setRequestHeader("User-Agent", this.getUserAgent()); }
/** * Prepares a HttpMethod object. * * @param method The object which gets prepared to access the file object. * @throws FileSystemException if an error occurs. * @throws URIException if path cannot be represented. * @since 2.0 (was package) */ protected void setupMethod(final HttpMethod method) throws FileSystemException, URIException { final String pathEncoded = ((URLFileName) getName()).getPathQueryEncoded(this.getUrlCharset()); method.setPath(pathEncoded); method.setFollowRedirects(this.getFollowRedirect()); method.setRequestHeader("User-Agent", this.getUserAgent()); }