@Override public String getCharacterEncoding() { return _contentType==null?null:MimeTypes.getCharsetFromContentType(_contentType); }
@Override public String getCharacterEncoding() { return _contentType==null?null:MimeTypes.getCharsetFromContentType(_contentType); }
@Override public String getCharacterEncoding() { return _contentType==null?null:MimeTypes.getCharsetFromContentType(_contentType); }
public String getContent() { if (_content==null) return null; byte[] bytes=_content.toByteArray(); String content_type=get(HttpHeader.CONTENT_TYPE); String encoding=MimeTypes.getCharsetFromContentType(content_type); Charset charset=encoding==null?StringUtil.__UTF8_CHARSET:Charset.forName(encoding); return new String(bytes,charset); }
@Override public void headerComplete() throws IOException { _contentType = _fields.get(HttpHeaders.CONTENT_TYPE_BUFFER); if(_contentType!=null) { String charset = MimeTypes.getCharsetFromContentType(_contentType); if(charset!=null) _charset = charset; } }
public String getContent() { if (_content==null) return null; byte[] bytes=_content.toByteArray(); String content_type=get(HttpHeader.CONTENT_TYPE); String encoding=MimeTypes.getCharsetFromContentType(content_type); Charset charset=encoding==null?StringUtil.__UTF8_CHARSET:Charset.forName(encoding); return new String(bytes,charset); }
public void headerComplete() throws IOException { _contentType = _fields.get(HttpHeaders.CONTENT_TYPE_BUFFER); if(_contentType!=null) { String charset = MimeTypes.getCharsetFromContentType(_contentType); if(charset!=null) _charset = charset; } }
public String getContent() { if (_content==null) return null; byte[] bytes=_content.toByteArray(); String content_type=get(HttpHeader.CONTENT_TYPE); String encoding=MimeTypes.getCharsetFromContentType(content_type); Charset charset=encoding==null?StandardCharsets.UTF_8:Charset.forName(encoding); return new String(bytes,charset); }
private String getParameterBytesAsString (String name, byte[] bytes) throws UnsupportedEncodingException { //check if there is a specific encoding for the parameter Object ct = _params.get(name+CONTENT_TYPE_SUFFIX); //use default if not String contentType = _encoding; if (ct != null) { String tmp = MimeTypes.getCharsetFromContentType(new ByteArrayBuffer((String)ct)); contentType = (tmp == null?_encoding:tmp); } return new String(bytes,contentType); } }
public void setContentType(String value) { _contentType = MimeTypes.CACHE.lookup(value); _charset = MimeTypes.getCharsetFromContentType(_contentType); _fields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); }
public PrintWriter getWriter() throws IOException { if (_outputState!=NONE && _outputState!=WRITER) throw new IllegalStateException("STREAM"); /* if there is no writer yet */ if (_writer==null) { /* get encoding from Content-Type header */ String encoding = _characterEncoding; if (encoding==null) { /* implementation of educated defaults */ if(_cachedMimeType != null) encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType); if (encoding==null) encoding = StringUtil.__ISO_8859_1; setCharacterEncoding(encoding); } /* construct Writer using correct encoding */ _writer = _connection.getPrintWriter(encoding); } _outputState=WRITER; return _writer; }
public PrintWriter getWriter() throws IOException { if (_outputState!=NONE && _outputState!=WRITER) throw new IllegalStateException("STREAM"); /* if there is no writer yet */ if (_writer==null) { /* get encoding from Content-Type header */ String encoding = _characterEncoding; if (encoding==null) { /* implementation of educated defaults */ if(_cachedMimeType != null) encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType); if (encoding==null) encoding = StringUtil.__ISO_8859_1; setCharacterEncoding(encoding); } /* construct Writer using correct encoding */ _writer = _connection.getPrintWriter(encoding); } _outputState=WRITER; return _writer; }
public PrintWriter getWriter() throws IOException { if (_outputState!=NONE && _outputState!=WRITER) throw new IllegalStateException("STREAM"); /* if there is no writer yet */ if (_writer==null) { /* get encoding from Content-Type header */ String encoding = _characterEncoding; if (encoding==null) { /* implementation of educated defaults */ if(_cachedMimeType != null) encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType); if (encoding==null) encoding = StringUtil.__ISO_8859_1; setCharacterEncoding(encoding); } /* construct Writer using correct encoding */ _writer = _connection.getPrintWriter(encoding); } _outputState=WRITER; return _writer; }
public PrintWriter getWriter() throws IOException { if (_outputState!=NONE && _outputState!=WRITER) throw new IllegalStateException("STREAM"); /* if there is no writer yet */ if (_writer==null) { /* get encoding from Content-Type header */ String encoding = _characterEncoding; if (encoding==null) { /* implementation of educated defaults */ if(_cachedMimeType != null) encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType); if (encoding==null) encoding = StringUtil.__ISO_8859_1; setCharacterEncoding(encoding); } /* construct Writer using correct encoding */ _writer = _connection.getPrintWriter(encoding); } _outputState=WRITER; return _writer; }
public PrintWriter getWriter() throws IOException { if (_outputState!=NONE && _outputState!=WRITER) throw new IllegalStateException("STREAM"); /* if there is no writer yet */ if (_writer==null) { /* get encoding from Content-Type header */ String encoding = _characterEncoding; if (encoding==null) { /* implementation of educated defaults */ if(_cachedMimeType != null) encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType); if (encoding==null) encoding = StringUtil.__ISO_8859_1; setCharacterEncoding(encoding); } /* construct Writer using correct encoding */ _writer = _connection.getPrintWriter(encoding); } _outputState=WRITER; return _writer; }
@Override public String getContentType() { String content_type = _metadata.getFields().get(HttpHeader.CONTENT_TYPE); if (_characterEncoding==null && content_type!=null) { MimeTypes.Type mime = MimeTypes.CACHE.get(content_type); String charset = (mime == null || mime.getCharset() == null) ? MimeTypes.getCharsetFromContentType(content_type) : mime.getCharset().toString(); if (charset != null) _characterEncoding=charset; } return content_type; }
@Override public String getContentType() { MetaData.Request metadata = _metaData; String content_type = metadata==null?null:metadata.getFields().get(HttpHeader.CONTENT_TYPE); if (_characterEncoding==null && content_type!=null) { MimeTypes.Type mime = MimeTypes.CACHE.get(content_type); String charset = (mime == null || mime.getCharset() == null) ? MimeTypes.getCharsetFromContentType(content_type) : mime.getCharset().toString(); if (charset != null) _characterEncoding=charset; } return content_type; }
CachedHttpContent(String pathInContext,Resource resource,CachedHttpContent gzipped) { _key=pathInContext; _resource=resource; String contentType = _mimeTypes.getMimeByExtension(_resource.toString()); _contentType=contentType==null?null:new PreEncodedHttpField(HttpHeader.CONTENT_TYPE,contentType); _characterEncoding = _contentType==null?null:MimeTypes.getCharsetFromContentType(contentType); _mimeType = _contentType==null?null:MimeTypes.CACHE.get(MimeTypes.getContentTypeWithoutCharset(contentType)); boolean exists=resource.exists(); _lastModifiedValue=exists?resource.lastModified():-1L; _lastModified=_lastModifiedValue==-1?null :new PreEncodedHttpField(HttpHeader.LAST_MODIFIED,DateGenerator.formatDate(_lastModifiedValue)); _contentLengthValue=exists?(int)resource.length():0; _contentLength=new PreEncodedHttpField(HttpHeader.CONTENT_LENGTH,Long.toString(_contentLengthValue)); if (_cachedFiles.incrementAndGet()>_maxCachedFiles) shrinkCache(); _lastAccessed=System.currentTimeMillis(); _etag=ResourceCache.this._etags?new PreEncodedHttpField(HttpHeader.ETAG,resource.getWeakETag()):null; _gzipped=gzipped==null?null:new CachedGzipHttpContent(this,gzipped); }
charset = MimeTypes.getCharsetFromContentType(mp.getContentType());
if(_contentType!=null) String charset = MimeTypes.getCharsetFromContentType(_contentType); if(charset!=null) _charset = charset;