Java Code Examples for org.apache.commons.httpclient.header#getElements()
The following examples show how to use
org.apache.commons.httpclient.header#getElements() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlexGetMethod.java From flex-blazeds with Apache License 2.0 | 6 votes |
protected String getContentCharSet(Header contentheader) { String charset = null; if (contentheader != null) { HeaderElement values[] = contentheader.getElements(); if (values.length == 1) { NameValuePair param = values[0].getParameterByName("charset"); if (param != null) { charset = param.getValue(); } } } if (charset == null) { charset = "UTF-8"; } return charset; }
Example 2
Source File: FlexPostMethod.java From flex-blazeds with Apache License 2.0 | 6 votes |
protected String getContentCharSet(Header contentheader) { String charset = null; if (contentheader != null) { HeaderElement values[] = contentheader.getElements(); if (values.length == 1) { NameValuePair param = values[0].getParameterByName("charset"); if (param != null) { charset = param.getValue(); } } } if (charset == null) { charset = "UTF-8"; } return charset; }
Example 3
Source File: HttpFileContentInfoFactory.java From commons-vfs with Apache License 2.0 | 6 votes |
@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); }