/** * {@inheritDoc} */ @Override public String getCharset() throws DereferenceException { if (charsetFetched) { return charsetName; } charsetFetched = true; if (!httpUrl.getProtocol().equals("http") && !httpUrl.getProtocol().equals("https")) { charsetName = null; return null; } HeadMethod method = new HeadMethod(httpUrl.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); charsetName = method.getResponseCharSet(); return charsetName; } catch (HttpException e) { // throw new DereferenceException(e); } catch (IOException e) { // throw new DereferenceException(e); } finally { method.releaseConnection(); } charsetName = null; return null; }
@Override public String getCharset() throws DereferenceException { if (charsetFetched) return charsetName; charsetFetched = true; if (!httpUrl.getProtocol().equals("http") && !httpUrl.getProtocol().equals("https")) { charsetName = null; return null; } HeadMethod method = new HeadMethod(httpUrl.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); charsetName = method.getResponseCharSet(); return charsetName; } catch (HttpException e) { // throw new DereferenceException(e); } catch (IOException e) { // throw new DereferenceException(e); } finally { method.releaseConnection(); } charsetName = null; return null; }
public String getCharset() throws DereferenceException { if (!url.getProtocol().equals("http")) { return null; // Don't know } HeadMethod method = new HeadMethod(url.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); return method.getResponseCharSet(); } catch (HttpException e) { throw new DereferenceException(e); } catch (IOException e) { throw new DereferenceException(e); } finally { method.releaseConnection(); } } }
/** * {@inheritDoc} */ @Override public String getCharset() throws DereferenceException { if (!httpUrl.getProtocol().equals("http")) { return null; // Don't know } HeadMethod method = new HeadMethod(httpUrl.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); return method.getResponseCharSet(); } catch (HttpException e) { throw new DereferenceException(e); } catch (IOException e) { throw new DereferenceException(e); } finally { method.releaseConnection(); } }
/** * {@inheritDoc} */ @Override public String getCharset() throws DereferenceException { if (!httpUrl.getProtocol().equals("http")) { return null; // Don't know } HeadMethod method = new HeadMethod(httpUrl.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); return method.getResponseCharSet(); } catch (HttpException e) { throw new DereferenceException(e); } catch (IOException e) { throw new DereferenceException(e); } finally { method.releaseConnection(); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { String contentType = null; String contentEncoding = null; HeadMethod headMethod; try (final HttpFileObject<HttpFileSystem> httpFile = (HttpFileObject<HttpFileSystem>) FileObjectUtils .getAbstractFileObject(fileContent.getFile())) { headMethod = httpFile.getHeadMethod(); } catch (final IOException e) { throw new FileSystemException(e); } final Header header = headMethod.getResponseHeader("content-type"); if (header != null) { final HeaderElement[] element = header.getElements(); if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = headMethod.getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final HttpFileObject httpFile = (HttpFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; HeadMethod headMethod; try { headMethod = httpFile.getHeadMethod(); } catch (final IOException e) { throw new FileSystemException(e); } final Header header = headMethod.getResponseHeader("content-type"); if (header != null) { final HeaderElement[] element = header.getElements(); if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = headMethod.getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final HttpFileObject httpFile = (HttpFileObject) FileObjectUtils.getAbstractFileObject(fileContent.getFile()); String contentType = null; String contentEncoding = null; HeadMethod headMethod; try { headMethod = httpFile.getHeadMethod(); } catch (final IOException e) { throw new FileSystemException(e); } final Header header = headMethod.getResponseHeader("content-type"); if (header != null) { final HeaderElement[] element = header.getElements(); if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = headMethod.getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }
public FileContentInfo create(FileContent fileContent) throws FileSystemException { HttpFileObject httpFile = (HttpFileObject) fileContent.getFile(); String contentType = null; String contentEncoding = null; Header header = httpFile.getHeadMethod().getResponseHeader("content-type"); if (header != null) { HeaderElement[] element; try { element = header.getValues(); } catch (HttpException e) { throw new FileSystemException(e); } if (element != null && element.length > 0) { contentType = element[0].getName(); } } contentEncoding = httpFile.getHeadMethod().getResponseCharSet(); return new DefaultFileContentInfo(contentType, contentEncoding); } }