Returns the content type returned from the server, e.g. "text/html". @return the content type returned from the server, e.g. "text/html"
()
| 140 | * @return the content type returned from the server, e.g. "text/html" |
| 141 | */ |
| 142 | public String getContentType() { |
| 143 | final String contentTypeHeader = getResponseHeaderValue(HttpHeader.CONTENT_TYPE_LC); |
| 144 | if (contentTypeHeader == null) { |
| 145 | // Not technically legal but some servers don't return a content-type |
| 146 | return ""; |
| 147 | } |
| 148 | final int index = contentTypeHeader.indexOf(';'); |
| 149 | if (index == -1) { |
| 150 | return contentTypeHeader; |
| 151 | } |
| 152 | return contentTypeHeader.substring(0, index); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Returns the content charset specified explicitly in the {@code Content-Type} header |