List of usage examples for org.apache.commons.httpclient.methods HeadMethod getResponseCharSet
public String getResponseCharSet()
From source file:net.sf.taverna.t2.reference.impl.external.http.HttpReference.java
@Override public String getCharset() throws DereferenceException { if (charsetFetched) return charsetName; charsetFetched = true;/*from w w w .j a v a 2 s. c o m*/ 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; }
From source file:com.datos.vfs.provider.http.HttpFileContentInfoFactory.java
@Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final HttpFileObject httpFile = (HttpFileObject) FileObjectUtils .getAbstractFileObject(fileContent.getFile()); String contentType = null;/* w w w . j a v a2 s .c o m*/ 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); }