//
// ========================================================================
-// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
protected InputStream _in;
protected MultipartConfigElement _config;
protected String _contentType;
- protected MultiMap _parts;
+ protected MultiMap<Part> _parts;
protected File _tmpDir;
protected File _contextTmpDir;
protected boolean _deleteOnExit;
protected OutputStream _out;
protected ByteArrayOutputStream2 _bout;
protected String _contentType;
- protected MultiMap _headers;
+ protected MultiMap<String> _headers;
protected long _size = 0;
protected boolean _temporary = true;
protected void open()
throws IOException
{
- //We will either be writing to a file, if it has a filename on the content-disposition
- //and otherwise a byte-array-input-stream, OR if we exceed the getFileSizeThreshold, we
- //will need to change to write to a file.
- if (_filename != null && _filename.trim().length() > 0)
- {
- createFile();
- }
- else
- {
- //Write to a buffer in memory until we discover we've exceed the
- //MultipartConfig fileSizeThreshold
- _out = _bout= new ByteArrayOutputStream2();
- }
+ //Write to a buffer in memory until we discover we've exceed the
+ //MultipartConfig fileSizeThreshold
+ _out = _bout= new ByteArrayOutputStream2();
}
protected void close()
if (MultiPartInputStreamParser.this._config.getFileSizeThreshold() > 0 && _size + 1 > MultiPartInputStreamParser.this._config.getFileSizeThreshold() && _file==null)
createFile();
+
_out.write(b);
_size ++;
}
if (MultiPartInputStreamParser.this._config.getFileSizeThreshold() > 0 && _size + length > MultiPartInputStreamParser.this._config.getFileSizeThreshold() && _file==null)
createFile();
-
+
_out.write(bytes, offset, length);
_size += length;
}
throws IOException
{
_file = File.createTempFile("MultiPart", "", MultiPartInputStreamParser.this._tmpDir);
+
if (_deleteOnExit)
_file.deleteOnExit();
FileOutputStream fos = new FileOutputStream(_file);
- protected void setHeaders(MultiMap headers)
+ protected void setHeaders(MultiMap<String> headers)
{
_headers = headers;
}
if (_parts == null)
return Collections.emptyList();
- Collection<Object> values = _parts.values();
+ Collection<List<Part>> values = _parts.values();
List<Part> parts = new ArrayList<Part>();
- for (Object o: values)
+ for (List<Part> o: values)
{
List<Part> asList = LazyList.getList(o, false);
parts.addAll(asList);
throws IOException, ServletException
{
parse();
- Collection<Object> values = _parts.values();
+ Collection<List<Part>> values = _parts.values();
List<Part> parts = new ArrayList<Part>();
- for (Object o: values)
+ for (List<Part> o: values)
{
List<Part> asList = LazyList.getList(o, false);
parts.addAll(asList);
//initialize
long total = 0; //keep running total of size of bytes read from input and throw an exception if exceeds MultipartConfigElement._maxRequestSize
- _parts = new MultiMap();
+ _parts = new MultiMap<Part>();
//if its not a multipart request, don't parse it
if (_contentType == null || !_contentType.startsWith("multipart/form-data"))
String contentType=null;
String contentTransferEncoding=null;
- MultiMap headers = new MultiMap();
+ MultiMap<String> headers = new MultiMap<String>();
while(true)
{
line=((ReadLineInputStream)_in).readLine();