public SseEventInputImpl(final Annotation[] annotations, final MediaType streamType, final MediaType elementType, final MultivaluedMap<String, String> httpHeaders, final InputStream inputStream) { this.annotations = annotations; this.mediaType = elementType; this.httpHeaders = httpHeaders; this.inputStream = inputStream; this.textLike = MediaTypeHelper.isTextLike(streamType); this.escape = streamType != null && streamType.toString().startsWith("application/x-stream-general"); }
protected BrowserCache.Entry getEntry(ClientRequestContext request) throws Exception { String uri = request.getUri().toString(); List<MediaType> acceptableMediaTypes = request.getAcceptableMediaTypes(); BrowserCache.Entry entry = null; if (acceptableMediaTypes.size() > 0) { for (MediaType accept : acceptableMediaTypes) { entry = cache.get(uri, accept); if (entry != null) return entry; if (MediaTypeHelper.isTextLike(accept)) { entry = cache.get(uri, accept.withCharset("UTF-8")); if (entry != null) return entry; } } } else { return cache.getAny(uri); } return null; }
public static MediaType getResponseMediaType(BuiltResponse jaxrsResponse, HttpRequest request, HttpResponse response, ResteasyProviderFactory providerFactory, ResourceMethodInvoker method) { MediaType mt = null; if (!jaxrsResponse.isClosed() && jaxrsResponse.getEntity() != null) { if ((mt = jaxrsResponse.getMediaType()) == null) { mt = getDefaultContentType(request, jaxrsResponse, providerFactory, method); } boolean addCharset = true; ResteasyDeployment deployment = ResteasyContext.getContextData(ResteasyDeployment.class); if (deployment != null) { addCharset = deployment.isAddCharset(); } if (addCharset) { if (!mt.getParameters().containsKey(MediaType.CHARSET_PARAMETER)) { if (MediaTypeHelper.isTextLike(mt)) { mt = mt.withCharset(StandardCharsets.UTF_8.toString()); } } } } return mt; }
boolean textLike = MediaTypeHelper.isTextLike(mediaType); boolean escape = event instanceof OutboundSseEventImpl ? ((OutboundSseEventImpl)event).isEscape() : false; if (event.getComment() != null)
public SseEventInputImpl(final Annotation[] annotations, final MediaType streamType, final MediaType elementType, final MultivaluedMap<String, String> httpHeaders, final InputStream inputStream) { this.annotations = annotations; this.mediaType = elementType; this.httpHeaders = httpHeaders; this.inputStream = inputStream; this.textLike = MediaTypeHelper.isTextLike(streamType); this.escape = streamType != null && streamType.toString().startsWith("application/x-stream-general"); }
protected BrowserCache.Entry getEntry(ClientRequestContext request) throws Exception { String uri = request.getUri().toString(); List<MediaType> acceptableMediaTypes = request.getAcceptableMediaTypes(); BrowserCache.Entry entry = null; if (acceptableMediaTypes.size() > 0) { for (MediaType accept : acceptableMediaTypes) { entry = cache.get(uri, accept); if (entry != null) return entry; if (MediaTypeHelper.isTextLike(accept)) { entry = cache.get(uri, accept.withCharset("UTF-8")); if (entry != null) return entry; } } } else { return cache.getAny(uri); } return null; }
public ResourceMethodBuilder produces(String... produces) { MediaType[] types = parseMediaTypes(produces); method.produces = types; for (MediaType mt : types) { if (!mt.getParameters().containsKey(MediaType.CHARSET_PARAMETER)) { if (MediaTypeHelper.isTextLike(mt)) { ResteasyDeployment deployment = ResteasyProviderFactory.getContextData(ResteasyDeployment.class); if (deployment != null && !deployment.isAddCharset()) { LogMessages.LOGGER.mediaTypeLacksCharset(mt, method.getMethod().getName()); } } } } return this; }
protected BrowserCache.Entry getEntry(ClientRequestContext request) throws Exception { String uri = request.getUri().toString(); List<MediaType> acceptableMediaTypes = request.getAcceptableMediaTypes(); BrowserCache.Entry entry = null; if (acceptableMediaTypes.size() > 0) { for (MediaType accept : acceptableMediaTypes) { entry = cache.get(uri, accept); if (entry != null) return entry; if (MediaTypeHelper.isTextLike(accept)) { entry = cache.get(uri, accept.withCharset("UTF-8")); if (entry != null) return entry; } } } else { return cache.getAny(uri); } return null; }
if (MediaTypeHelper.isTextLike(accept))
if (MediaTypeHelper.isTextLike(mt))
boolean textLike = MediaTypeHelper.isTextLike(mediaType); boolean escape = event instanceof OutboundSseEventImpl ? ((OutboundSseEventImpl)event).isEscape() : false; if (event.getComment() != null)
public static MediaType getResponseMediaType(BuiltResponse jaxrsResponse, HttpRequest request, HttpResponse response, ResteasyProviderFactory providerFactory, ResourceMethodInvoker method) { MediaType mt = null; if (!jaxrsResponse.isClosed() && jaxrsResponse.getEntity() != null) { if ((mt = jaxrsResponse.getMediaType()) == null) { mt = getDefaultContentType(request, jaxrsResponse, providerFactory, method); } boolean addCharset = true; ResteasyDeployment deployment = ResteasyContext.getContextData(ResteasyDeployment.class); if (deployment != null) { addCharset = deployment.isAddCharset(); } if (addCharset) { if (!mt.getParameters().containsKey(MediaType.CHARSET_PARAMETER)) { if (MediaTypeHelper.isTextLike(mt)) { mt = mt.withCharset(StandardCharsets.UTF_8.toString()); } } } } return mt; }