TypedInputStreamHttp(InputStream input, MediaType mt, ClientConnectionManager connectMgr) { super(input, mt.getContentType(), mt.getCharset(), null) ; this.connectMgr = connectMgr ; }
public String toHeaderString() { return mediaType.toHeaderString() ; }
public static String getCharsetForContentType(String contentType) { MediaType ct = MediaType.create(contentType) ; if ( ct.getCharset() != null ) return ct.getCharset() ; String mt = ct.getContentType() ; if ( contentTypeNTriples.equals(mt) ) return charsetUTF8 ; if ( contentTypeNTriplesAlt.equals(mt) ) return charsetASCII ; if ( contentTypeNQuads.equals(mt) ) return charsetUTF8 ; if ( contentTypeNQuadsAlt1.equals(mt) ) return charsetASCII ; if ( contentTypeNQuadsAlt2.equals(mt) ) return charsetASCII ; return charsetUTF8 ; }
public String getMediaType() { return mediaType.getContentType() ; } public String getCharset() { return mediaType.getCharset() ; }
public boolean grounded(MediaType item) { return ! isStar(item.getType()) && ! isStar(item.getSubType()) ; }
public TypedOutputStream(OutputStream out, String mediaType, String charset) { this(out, MediaType.create(mediaType, charset)) ; }
@Test void should_get_for_graphiql() throws Exception { Thread.sleep(1000); final String path = basePath + config.getGraphqlConfig().port() + config.getGraphqlConfig().graphiQLPath(); final Envelope envelope = getPath(path, "application/json"); final String contentType = envelope.getContentType(); assertNotNull(contentType); final MediaType mediaType = MediaType.createFromContentType(contentType); assertEquals("text/html", mediaType.getContentType()); }
@Override public boolean equals(Object obj) { if (this == obj) return true ; if (obj == null) return false ; if (getClass() != obj.getClass()) return false ; ContentType other = (ContentType)obj ; if (mediaType == null) { if (other.mediaType != null) return false ; } else if (!mediaType.equals(other.mediaType)) return false ; return true ; }
public String getCharset() { return mediaType.getCharset() ; }
public static MediaType create(String contentType, String subType, String charset) { return new MediaType(contentType, subType, charset) ; }
@Override public int hashCode() { final int prime = 31 ; int result = 1 ; result = prime * result + ((mediaType == null) ? 0 : mediaType.hashCode()) ; return result ; }
public String getCharset() { return getParameter(strCharset) ; }
public String getType() { return mediaType.getType() ; }
public String getSubType() { return mediaType.getSubType() ; }
public String getContentType() { return mediaType.getContentType() ; }
public boolean grounded(MediaType item) { return ! isStar(item.getType()) && ! isStar(item.getSubType()) ; }
TypedInputStreamHttp(InputStream input, String contentType, ClientConnectionManager connectMgr) { this(input, MediaType.create(contentType), connectMgr) ; }
@Override public boolean equals(Object obj) { if ( this == obj ) return true ; if ( obj == null ) return false ; if ( getClass() != obj.getClass() ) return false ; ContentType other = (ContentType)obj ; if ( mediaType == null ) { if ( other.mediaType != null ) return false ; } else if ( !mediaType.equals(other.mediaType) ) return false ; return true ; }