Package org.eclipse.jetty.client.util
Class MultiPartContentProvider
- java.lang.Object
-
- org.eclipse.jetty.client.util.AbstractTypedContentProvider
-
- org.eclipse.jetty.client.util.MultiPartContentProvider
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ByteBuffer>
,ContentProvider
,ContentProvider.Typed
,AsyncContentProvider
@Deprecated(since="2021-05-27") public class MultiPartContentProvider extends AbstractTypedContentProvider implements AsyncContentProvider, Closeable
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.A
ContentProvider
for form uploads with the"multipart/form-data"
content type.Example usage:
MultiPartContentProvider multiPart = new MultiPartContentProvider(); multiPart.addFieldPart("field", new StringContentProvider("foo"), null); multiPart.addFilePart("icon", "img.png", new PathContentProvider(Paths.get("/tmp/img.png")), null); multiPart.close(); ContentResponse response = client.newRequest("localhost", connector.getLocalPort()) .method(HttpMethod.POST) .content(multiPart) .send();
The above example would be the equivalent of submitting this form:
<form method="POST" enctype="multipart/form-data" accept-charset="UTF-8"> <input type="text" name="field" value="foo" /> <input type="file" name="icon" /> </form>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.AsyncContentProvider
AsyncContentProvider.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.ContentProvider
ContentProvider.Typed
-
-
Constructor Summary
Constructors Constructor Description MultiPartContentProvider()
Deprecated.MultiPartContentProvider(String boundary)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addFieldPart(String name, ContentProvider content, HttpFields fields)
Deprecated.Adds a field part with the givenname
as field name, and the givencontent
as part content.void
addFilePart(String name, String fileName, ContentProvider content, HttpFields fields)
Deprecated.Adds a file part with the givenname
as field name, the givenfileName
as file name, and the givencontent
as part content.void
close()
Deprecated.long
getLength()
Deprecated.Iterator<ByteBuffer>
iterator()
Deprecated.void
setListener(AsyncContentProvider.Listener listener)
Deprecated.-
Methods inherited from class org.eclipse.jetty.client.util.AbstractTypedContentProvider
getContentType
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.api.ContentProvider
isReproducible
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MultiPartContentProvider
public MultiPartContentProvider()
Deprecated.
-
MultiPartContentProvider
public MultiPartContentProvider(String boundary)
Deprecated.
-
-
Method Detail
-
addFieldPart
public void addFieldPart(String name, ContentProvider content, HttpFields fields)
Deprecated.Adds a field part with the given
name
as field name, and the givencontent
as part content.The
Content-Type
of this part will be obtained from:- the
Content-Type
header in thefields
parameter; otherwise - the
ContentProvider.Typed.getContentType()
method if thecontent
parameter implementsContentProvider.Typed
; otherwise - "text/plain"
- Parameters:
name
- the part namecontent
- the part contentfields
- the headers associated with this part
- the
-
addFilePart
public void addFilePart(String name, String fileName, ContentProvider content, HttpFields fields)
Deprecated.Adds a file part with the given
name
as field name, the givenfileName
as file name, and the givencontent
as part content.The
Content-Type
of this part will be obtained from:- the
Content-Type
header in thefields
parameter; otherwise - the
ContentProvider.Typed.getContentType()
method if thecontent
parameter implementsContentProvider.Typed
; otherwise - "application/octet-stream"
- Parameters:
name
- the part namefileName
- the file name associated to this partcontent
- the part contentfields
- the headers associated with this part
- the
-
setListener
public void setListener(AsyncContentProvider.Listener listener)
Deprecated.- Specified by:
setListener
in interfaceAsyncContentProvider
- Parameters:
listener
- the listener to be notified of content availability
-
getLength
public long getLength()
Deprecated.- Specified by:
getLength
in interfaceContentProvider
- Returns:
- the content length, if known, or -1 if the content length is unknown
-
iterator
public Iterator<ByteBuffer> iterator()
Deprecated.- Specified by:
iterator
in interfaceIterable<ByteBuffer>
-
close
public void close()
Deprecated.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-