/** * Returns the charset specified on the <code>Content-Type</code> header, or <js>"UTF-8"</js> if not specified. */ @Override /* ServletRequest */ public String getCharacterEncoding() throws UnsupportedMediaType { if (charset == null) { // Determine charset // NOTE: Don't use super.getCharacterEncoding() because the spec is implemented inconsistently. // Jetty returns the default charset instead of null if the character is not specified on the request. String h = getHeader("Content-Type"); if (h != null) { int i = h.indexOf(";charset="); if (i > 0) charset = h.substring(i+9).trim(); } if (charset == null && restJavaMethod != null) charset = restJavaMethod.defaultCharset; if (charset == null) charset = "UTF-8"; if (! Charset.isSupported(charset)) throw new UnsupportedMediaType("Unsupported charset in header ''Content-Type'': ''{0}''", h); } return charset; }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public UnsupportedMediaType(String msg) { super(msg); setStatus(CODE); }
/** * Returns the charset specified on the <code>Content-Type</code> header, or <js>"UTF-8"</js> if not specified. */ @Override /* ServletRequest */ public String getCharacterEncoding() throws UnsupportedMediaType { if (charset == null) { // Determine charset // NOTE: Don't use super.getCharacterEncoding() because the spec is implemented inconsistently. // Jetty returns the default charset instead of null if the character is not specified on the request. String h = getHeader("Content-Type"); if (h != null) { int i = h.indexOf(";charset="); if (i > 0) charset = h.substring(i+9).trim(); } if (charset == null && restJavaMethod != null) charset = restJavaMethod.defaultCharset; if (charset == null) charset = "UTF-8"; if (! Charset.isSupported(charset)) throw new UnsupportedMediaType("Unsupported charset in header ''Content-Type'': ''{0}''", h); } return charset; }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public UnsupportedMediaType(String msg) { super(msg); setStatus(CODE); }
/** * Returns the charset specified on the <code>Content-Type</code> header, or <js>"UTF-8"</js> if not specified. */ @Override /* ServletRequest */ public String getCharacterEncoding() throws UnsupportedMediaType { if (charset == null) { // Determine charset // NOTE: Don't use super.getCharacterEncoding() because the spec is implemented inconsistently. // Jetty returns the default charset instead of null if the character is not specified on the request. String h = getHeader("Content-Type"); if (h != null) { int i = h.indexOf(";charset="); if (i > 0) charset = h.substring(i+9).trim(); } if (charset == null && restJavaMethod != null) charset = restJavaMethod.defaultCharset; if (charset == null) charset = "UTF-8"; if (! Charset.isSupported(charset)) throw new UnsupportedMediaType("Unsupported charset in header ''Content-Type'': ''{0}''", h); } return charset; }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public UnsupportedMediaType(String msg) { super(msg); setStatus(CODE); }
@RestMethod public void unsupportedMediaType() { throw new UnsupportedMediaType(); } @RestMethod public void upgradeRequired() { throw new UpgradeRequired(); }
@RestMethod public void unsupportedMediaType() { throw new UnsupportedMediaType("foo {0}", "bar"); } @RestMethod public void upgradeRequired() { throw new UpgradeRequired("foo {0}", "bar"); }
@RestMethod public void unsupportedMediaType() { throw new UnsupportedMediaType(t, "foo {0}", "bar"); } @RestMethod public void upgradeRequired() { throw new UpgradeRequired(t, "foo {0}", "bar"); }
@RestMethod public void unsupportedMediaType() { throw new UnsupportedMediaType(t); } @RestMethod public void upgradeRequired() { throw new UpgradeRequired(t); }
private Encoder getEncoder() throws UnsupportedMediaType { if (encoder == null) { String ce = req.getHeader("content-encoding"); if (isNotEmpty(ce)) { ce = ce.trim(); encoder = encoders.getEncoder(ce); if (encoder == null) throw new UnsupportedMediaType( "Unsupported encoding in request header ''Content-Encoding'': ''{0}''\n\tSupported codings: {1}", req.getHeader("content-encoding"), encoders.getSupportedEncodings() ); } if (encoder != null) contentLength = -1; } // Note that if this is the identity encoder, we want to return null // so that we don't needlessly wrap the input stream. if (encoder == IdentityEncoder.INSTANCE) return null; return encoder; }
private Encoder getEncoder() throws UnsupportedMediaType { if (encoder == null) { String ce = req.getHeader("content-encoding"); if (isNotEmpty(ce)) { ce = ce.trim(); encoder = encoders.getEncoder(ce); if (encoder == null) throw new UnsupportedMediaType( "Unsupported encoding in request header ''Content-Encoding'': ''{0}''\n\tSupported codings: {1}", req.getHeader("content-encoding"), encoders.getSupportedEncodings() ); } if (encoder != null) contentLength = -1; } // Note that if this is the identity encoder, we want to return null // so that we don't needlessly wrap the input stream. if (encoder == IdentityEncoder.INSTANCE) return null; return encoder; }
private Encoder getEncoder() throws UnsupportedMediaType { if (encoder == null) { String ce = req.getHeader("content-encoding"); if (isNotEmpty(ce)) { ce = ce.trim(); encoder = encoders.getEncoder(ce); if (encoder == null) throw new UnsupportedMediaType( "Unsupported encoding in request header ''Content-Encoding'': ''{0}''\n\tSupported codings: {1}", req.getHeader("content-encoding"), encoders.getSupportedEncodings() ); } if (encoder != null) contentLength = -1; } // Note that if this is the identity encoder, we want to return null // so that we don't needlessly wrap the input stream. if (encoder == IdentityEncoder.INSTANCE) return null; return encoder; }
throw new UnsupportedMediaType("Could not find parser for media type ''{0}''", contentType); RemoteInterfaceMeta rim = getInterfaceClass(javaInterface);
throw new UnsupportedMediaType("Could not find parser for media type ''{0}''", contentType); RemoteInterfaceMeta rim = getInterfaceClass(javaInterface);
throw new UnsupportedMediaType("Could not find parser for media type ''{0}''", contentType); RemoteInterfaceMeta rim = getInterfaceClass(javaInterface);
return cm.getStringTransform().transform(asString()); throw new UnsupportedMediaType( "Unsupported media-type in request header ''Content-Type'': ''{0}''\n\tSupported media-types: {1}", headers.getContentType(), req.getParsers().getSupportedMediaTypes()
return cm.getStringTransform().transform(asString()); throw new UnsupportedMediaType( "Unsupported media-type in request header ''Content-Type'': ''{0}''\n\tSupported media-types: {1}", headers.getContentType(), req.getParsers().getSupportedMediaTypes()
return cm.getStringTransform().transform(asString()); throw new UnsupportedMediaType( "Unsupported media-type in request header ''Content-Type'': ''{0}''\n\tSupported media-types: {1}", headers.getContentType(), req.getParsers().getSupportedMediaTypes()