public class MultipartParser extends Object
限定符和类型 | 字段和说明 |
---|---|
private String |
boundary
MIME boundary that delimits parts
|
private byte[] |
buf
buffer for readLine method
|
private static String |
DEFAULT_ENCODING
default encoding
|
private String |
encoding
preferred encoding
|
private javax.servlet.ServletInputStream |
in
input stream to read parts from
|
private FilePart |
lastFilePart
reference to the last file part we returned
|
构造器和说明 |
---|
MultipartParser(javax.servlet.http.HttpServletRequest req,
int maxSize)
Creates a
MultipartParser from the specified request,
which limits the upload size to the specified length, buffers for
performance and prevent attempts to read past the amount specified
by the Content-Length. |
MultipartParser(javax.servlet.http.HttpServletRequest req,
int maxSize,
boolean buffer,
boolean limitLength)
Creates a
MultipartParser from the specified request,
which limits the upload size to the specified length, and optionally
buffers for performance and prevents attempts to read past the amount
specified by the Content-Length. |
MultipartParser(javax.servlet.http.HttpServletRequest req,
int maxSize,
boolean buffer,
boolean limitLength,
String encoding)
Creates a
MultipartParser from the specified request,
which limits the upload size to the specified length, and optionally
buffers for performance and prevents attempts to read past the amount
specified by the Content-Length, and with a specified encoding. |
限定符和类型 | 方法和说明 |
---|---|
private String |
extractBoundary(String line)
Extracts and returns the boundary token from a line.
|
private static String |
extractContentType(String line)
Extracts and returns the content type from a line, or null if the
line was empty.
|
private String[] |
extractDispositionInfo(String line)
Extracts and returns disposition info from a line, as a
String |
private String |
readLine()
Read the next line of input.
|
Part |
readNextPart()
Read the next part arriving in the stream.
|
void |
setEncoding(String encoding)
Sets the encoding used to parse from here onward.
|
private javax.servlet.ServletInputStream in
private String boundary
private FilePart lastFilePart
private byte[] buf
private static String DEFAULT_ENCODING
private String encoding
public MultipartParser(javax.servlet.http.HttpServletRequest req, int maxSize) throws IOException
MultipartParser
from the specified request,
which limits the upload size to the specified length, buffers for
performance and prevent attempts to read past the amount specified
by the Content-Length.req
- the servlet request.maxSize
- the maximum size of the POST content.IOException
public MultipartParser(javax.servlet.http.HttpServletRequest req, int maxSize, boolean buffer, boolean limitLength) throws IOException
MultipartParser
from the specified request,
which limits the upload size to the specified length, and optionally
buffers for performance and prevents attempts to read past the amount
specified by the Content-Length.req
- the servlet request.maxSize
- the maximum size of the POST content.buffer
- whether to do internal buffering or let the server buffer,
useful for servers that don't bufferlimitLength
- boolean flag to indicate if we need to filter
the request's input stream to prevent trying to
read past the end of the stream.IOException
public MultipartParser(javax.servlet.http.HttpServletRequest req, int maxSize, boolean buffer, boolean limitLength, String encoding) throws IOException
MultipartParser
from the specified request,
which limits the upload size to the specified length, and optionally
buffers for performance and prevents attempts to read past the amount
specified by the Content-Length, and with a specified encoding.req
- the servlet request.maxSize
- the maximum size of the POST content.buffer
- whether to do internal buffering or let the server buffer,
useful for servers that don't bufferlimitLength
- boolean flag to indicate if we need to filter
the request's input stream to prevent trying to
read past the end of the stream.encoding
- the encoding to use for parsing, default is ISO-8859-1.IOException
public void setEncoding(String encoding)
encoding
- The encoding to use for parsingpublic Part readNextPart() throws IOException
FilePart
or a ParamPart
, or null
to indicate there are no more parts to read. The order of arrival
corresponds to the order of the form elements in the submitted form.FilePart
, a ParamPart
or
null
if there are no more parts to read.IOException
- if an input or output exception has occurred.FilePart
,
ParamPart
private String extractBoundary(String line)
private String[] extractDispositionInfo(String line) throws IOException
String
array with elements: disposition, name, filename.
IOException
- if the line is malformatted.private static String extractContentType(String line) throws IOException
IOException
- if the line is malformatted.private String readLine() throws IOException
IOException
- if an input or output exception has occurred.Copyright © 2021. All rights reserved.