/** * Creates a {@link ContentType} wrapper over a {@link String} * content-type representation. * * @param contentType {@link String} content-type representation * @return a {@link ContentType} wrapper over a {@link String} * content-type representation */ public static ContentType newContentType(final String contentType) { return new ContentType(contentType); }
@Override public String toString() { return get(); }
/** * Prepare the <tt>ContentType</tt> for the serialization. * * This method might be particularly useful if we use the same <tt>ContentType</tt> * over and over for different responses, so that the <tt>ContentType</tt> * will not have to be parsed and prepared for each response separately. * * @return this <tt>ContentType</tt> */ public ContentType prepare() { getByteArray(); return this; }
if (contentType.isMimeTypeSet()) { final DataChunk contentTypeValue = headers.setValue(Header.ContentType); if (contentTypeValue.isNull()) { contentType.serializeToDataChunk(contentTypeValue); contenTypeValue.setBytes(defaultResponseContentTypeBytes); } else { final byte[] array = ContentType.compose( defaultResponseContentTypeBytesNoCharset, ce); contenTypeValue.setBytes(array);
checkArray(compiledContentType.length()); compiledContentTypeArray = toCheckedByteArray(compiledContentType, array, 0); len = compiledContentType.length(); checkArray(unparsedContentType.length()); compiledContentTypeArray = toCheckedByteArray(unparsedContentType, array, 0); return compiledContentTypeArray; parse(); checkArray(len); } else { checkArray(mtsz); toCheckedByteArray(mimeType, array, 0); this.len = mtsz;
@Override public void service(Request request, Response response) throws Exception { if (request.getMethod().equals(Method.GET) && request.getRequestURI().endsWith("application.wsadl")) { getWsadlJaxbContext().createMarshaller().marshal(engine.getWsadlApplication(), response.getWriter()); response.setStatus(200); response.setContentType(ContentType.newContentType("application/wsadl+xml")); return; } if (staticHttpHandler != null) { staticHttpHandler.service(request, response); } else { response.sendError(404); } } }
/** * Prepares common response headers. */ private void prepareResponse(final FileCacheEntry entry, final HttpResponsePacket response) throws IOException { response.setContentType(entry.contentType.prepare()); if (entry.server != null) { response.addHeader(Header.Server, entry.server); } }
/** * Set the content type for this Response. * * @param type The new content type */ public void setContentType(final ContentType type) { checkResponse(); if (isCommitted()) return; if (type == null) { response.setContentType((String) null); return; } if (!usingWriter) { response.setContentType(type); } else { // Ignore charset if getWriter() has already been called response.setContentType(type.getMimeType()); } }
/** * @return <tt>true</tt> if either mime-type or character encoding is set, or * <tt>false</tt> otherwise */ public boolean isSet() { return isMimeTypeSet() || quotedCharsetValue != null; }
/** * Returns the mime-type part of the content-type (the part without charset attribute). * * @return the mime-type part of the content-type (the part without charset attribute) */ public String getMimeType() { if (!isParsed) { parse(); } return mimeType; }
if (contentType.isMimeTypeSet()) { final DataChunk contentTypeValue = headers.setValue(Header.ContentType); if (contentTypeValue.isNull()) { contentType.serializeToDataChunk(contentTypeValue); contenTypeValue.setBytes(defaultResponseContentTypeBytes); } else { final byte[] array = ContentType.compose( defaultResponseContentTypeBytesNoCharset, ce); contenTypeValue.setBytes(array);
checkArray(compiledContentType.length()); compiledContentTypeArray = toCheckedByteArray(compiledContentType, array, 0); len = compiledContentType.length(); checkArray(unparsedContentType.length()); compiledContentTypeArray = toCheckedByteArray(unparsedContentType, array, 0); return compiledContentTypeArray; parse(); checkArray(len); } else { checkArray(mtsz); toCheckedByteArray(mimeType, array, 0); this.len = mtsz;
entry.contentType = ContentType.newContentType(contentType); entry.xPoweredBy = headers.getHeader(Header.XPoweredBy); entry.date = headers.getHeader(Header.Date);
/** * Prepares common response headers. */ private void prepareResponse(final FileCacheEntry entry, final HttpResponsePacket response) throws IOException { response.setContentType(entry.contentType.prepare()); if (entry.server != null) { response.addHeader(Header.Server, entry.server); } }
/** * Set the content type for this Response. * * @param type The new content type */ public void setContentType(final ContentType type) { checkResponse(); if (isCommitted()) return; if (type == null) { response.setContentType((String) null); return; } if (!usingWriter) { response.setContentType(type); } else { // Ignore charset if getWriter() has already been called response.setContentType(type.getMimeType()); } }
/** * @return <tt>true</tt> if either mime-type or character encoding is set, or * <tt>false</tt> otherwise */ public boolean isSet() { return isMimeTypeSet() || quotedCharsetValue != null; }
/** * Returns the mime-type part of the content-type (the part without charset attribute). * * @return the mime-type part of the content-type (the part without charset attribute) */ public String getMimeType() { if (!isParsed) { parse(); } return mimeType; }
if (contentType.isMimeTypeSet()) { final DataChunk contentTypeValue = headers.setValue(Header.ContentType); if (contentTypeValue.isNull()) { contentType.serializeToDataChunk(contentTypeValue); contenTypeValue.setBytes(defaultResponseContentTypeBytes); } else { final byte[] array = ContentType.compose( defaultResponseContentTypeBytesNoCharset, ce); contenTypeValue.setBytes(array);
checkArray(compiledContentType.length()); compiledContentTypeArray = toCheckedByteArray(compiledContentType, array, 0); len = compiledContentType.length(); checkArray(unparsedContentType.length()); compiledContentTypeArray = toCheckedByteArray(unparsedContentType, array, 0); return compiledContentTypeArray; parse(); checkArray(len); } else { checkArray(mtsz); toCheckedByteArray(mimeType, array, 0); this.len = mtsz;
entry.contentType = ContentType.newContentType(contentType); entry.xPoweredBy = headers.getHeader(Header.XPoweredBy); entry.date = headers.getHeader(Header.Date);