Package ej.rest.web
Class Content
- java.lang.Object
-
- ej.rest.web.AbstractContent
-
- ej.rest.web.Content
-
- Direct Known Subclasses:
FormContent
public class Content extends AbstractContent
Class to encapsulate content being sent as payload of a POST or PUT request. You can use Resty.content(...) to create content objects.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]contentprotected Stringmime-
Fields inherited from class ej.rest.web.AbstractContent
CRLF
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddContent(URLConnection con)Add the content to the URLConnection used.voidwriteContent(OutputStream os)voidwriteHeader(OutputStream os)Used as a mime part, writing content headers-
Methods inherited from class ej.rest.web.AbstractContent
ascii, enc
-
-
-
-
Field Detail
-
mime
protected String mime
-
content
protected byte[] content
-
-
Constructor Detail
-
Content
public Content(String aMimeType, byte[] someBytes)
Create a new content object with given mime type and the content as bytes. No check if mime type is 'valid' or similar non-sense is done. You are all grown-ups.- Parameters:
aMimeType- the mime type. example: text/plain;charset=UTF-8someBytes- the content to deliver as bytes
-
-
Method Detail
-
addContent
protected void addContent(URLConnection con) throws IOException
Add the content to the URLConnection used.- Specified by:
addContentin classAbstractContent- Parameters:
con- the connection to use- Throws:
IOException- if writing to stream fails
-
writeContent
public void writeContent(OutputStream os) throws IOException
- Specified by:
writeContentin classAbstractContent- Throws:
IOException
-
writeHeader
public void writeHeader(OutputStream os) throws IOException
Used as a mime part, writing content headers- Specified by:
writeHeaderin classAbstractContent- Throws:
IOException
-
-