Class HttpServer.Part
java.lang.Object
com.codename1.backend.HttpServer.Part
- Enclosing class:
HttpServer
One part of a
multipart/form-data request body: a form field, or an
uploaded file when it has a filename.-
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBytes()The part's content.The part's Content-Type, or null when it declared none.The uploaded file's name as the client gave it, or null for a plain field.One of the part's own headers, by a name in any case; or null.The part's content as a stream, which is how to read a large upload: a part of a body that was spooled to disk is read from the spool file, never brought into memory whole.longThe part's content length in bytes.getName()The field name from its Content-Disposition, or null.intgetSize()The part's content length in bytes, capped atInteger.MAX_VALUE; seegetLength()for a part that may be larger.getText()The part's content as UTF-8 text.
-
Method Details
-
getName
The field name from its Content-Disposition, or null. -
getFilename
The uploaded file's name as the client gave it, or null for a plain field. Never use it as a path: it is whatever the client sent. -
getContentType
The part's Content-Type, or null when it declared none. -
getHeader
-
getSize
public int getSize()The part's content length in bytes, capped atInteger.MAX_VALUE; seegetLength()for a part that may be larger. -
getLength
public long getLength()The part's content length in bytes. -
getInputStream
The part's content as a stream, which is how to read a large upload: a part of a body that was spooled to disk is read from the spool file, never brought into memory whole. The stream is valid for the duration of the request; the file is gone once the response has been sent. -
getBytes
public byte[] getBytes()The part's content. The array is the part's; copy it to change it.- Throws:
IllegalStateException- for a part larger than the server's in-memory body limit (CN1_HTTP_MAX_BODY_MB), which only a spooled body can hold; read that one withgetInputStream()
-
getText
The part's content as UTF-8 text. Throws IllegalStateException when it is not valid UTF-8 -- a binary upload -- rather than returning replacement characters the client never sent.
-