Top Description Inners Constructors Methods
org.eclipse.jetty.http

public Class MultiPartByteRanges

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.nio.ByteBuffer, java.nio.channels.SeekableByteChannel, java.nio.file.Path, java.util.ArrayList, .Iterator, .List, java.util.concurrent.CompletableFuture, org.eclipse.jetty.io.Content, .RuntimeIOException, org.eclipse.jetty.io.content.ContentSourceCompletableFuture, org.eclipse.jetty.util.resource.Resource, org.eclipse.jetty.util.thread.AutoLock

A CompletableFuture that is completed when a multipart/byteranges has been parsed asynchronously from a Content.Source.

Once the parsing of the multipart/byteranges content completes successfully, objects of this class are completed with a MultiPartByteRanges.Parts object.

Typical usage:

// Some headers that include Content-Type.
HttpFields headers = ...;
String boundary = MultiPart.extractBoundary(headers.get(HttpHeader.CONTENT_TYPE));

// Some multipart/byteranges content.
Content.Source content = ...;

// Create and configure MultiPartByteRanges.
MultiPartByteRanges.Parser byteRanges = new MultiPartByteRanges.Parser(boundary);

// Parse the content.
byteRanges.parse(content)
    // When complete, use the parts.
    .thenAccept(parts -> ...);
See Also
Parts

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
MultiPartByteRanges.ContentSource

The multipart/byteranges specific content source.

public static class
public static class
public static class
MultiPartByteRanges.Part

A MultiPart.Part whose content is a byte range of a Resource.

public static class
MultiPartByteRanges.Parts

An ordered list of MultiPart.Parts that can be accessed by index, or iterated over.

public static class
MultiPartByteRanges.PathContentSource

A specialized org.eclipse.jetty.io.content.PathContentSource whose content is sliced by a byte range.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MultiPartByteRangesback to summary
private MultiPartByteRanges()
org.eclipse.jetty.http back to summary

public Class MultiPartByteRanges.ContentSource

extends AbstractContentSource
Class Inheritance

The multipart/byteranges specific content source.

See Also
MultiPart.AbstractContentSource

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
addPart(MultiPart.Part
the Part to add
part
)

Overrides org.eclipse.jetty.http.MultiPart.AbstractContentSource.addPart.

Adds, if possible, the given Part to this ContentSource.

Inherited from org.eclipse.jetty.http.MultiPart.AbstractContentSource:
closecustomizePartHeadersdemandfailgetBoundarygetLengthgetPartHeadersMaxLengthreadsetPartHeadersMaxLength

Constructor Detail

ContentSourceback to summary
public ContentSource(String boundary)

Method Detail

addPartback to summary
public boolean addPart(MultiPart.Part part)

Overrides org.eclipse.jetty.http.MultiPart.AbstractContentSource.addPart.

Doc from org.eclipse.jetty.http.MultiPart.AbstractContentSource.addPart.

Adds, if possible, the given Part to this ContentSource.

Parts may be added until this ContentSource is closed.

This method returns true if the part was added, false if the part cannot be added because this ContentSource is already closed, or because it has been failed.

Parameters
part:MultiPart.Part

the Part to add

Returns:boolean

whether the part has been added

Annotations
@Override
org.eclipse.jetty.http back to summary

public Class MultiPartByteRanges.InputStreamContentSource

extends InputStreamContentSource
Class Inheritance

A specialized org.eclipse.jetty.io.content.InputStreamContentSource whose content is sliced by a byte range.

Field Summary

Modifier and TypeField and Description
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected int
Inherited from org.eclipse.jetty.io.content.InputStreamContentSource:
demandfailgetBufferSizereadsetBufferSize

Field Detail

toReadback to summary
private long toRead

Constructor Detail

InputStreamContentSourceback to summary
public InputStreamContentSource(InputStream inputStream, ByteRange byteRange) throws IOException

Method Detail

fillBufferFromInputStreamback to summary
protected int fillBufferFromInputStream(InputStream inputStream, byte[] buffer) throws IOException

Overrides org.eclipse.jetty.io.content.InputStreamContentSource.fillBufferFromInputStream.

Annotations
@Override
org.eclipse.jetty.http back to summary

public Class MultiPartByteRanges.Parser

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final MultiPartByteRanges.Parser.PartsListener
private final MultiPart.Parser
private MultiPartByteRanges.Parts

Constructor Summary

AccessConstructor and Description
public
Parser(String boundary)

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the boundary string
getBoundary
()

public CompletableFuture<MultiPartByteRanges.Parts>
parse(Content.Source content)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listenerback to summary
private final MultiPartByteRanges.Parser.PartsListener listener
parserback to summary
private final MultiPart.Parser parser
partsback to summary
private MultiPartByteRanges.Parts parts

Constructor Detail

Parserback to summary
public Parser(String boundary)

Method Detail

getBoundaryback to summary
public String getBoundary()
Returns:String

the boundary string

parseback to summary
public CompletableFuture<MultiPartByteRanges.Parts> parse(Content.Source content)
org.eclipse.jetty.http back to summary

private Class MultiPartByteRanges.Parser.PartsListener

extends AbstractPartsListener
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Throwable
private final AutoLock
private final List<Content.Chunk>
private final List<MultiPart.Part>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
fail(Throwable cause)

private boolean
public void
onComplete()

Overrides default org.eclipse.jetty.http.MultiPart.Parser.Listener.onComplete.

Callback method invoked when the whole multipart content has been parsed.

public void
onFailure(Throwable
the failure cause
failure
)

Overrides default org.eclipse.jetty.http.MultiPart.Parser.Listener.onFailure.

Callback method invoked when the parser cannot parse the multipart content.

public void
onPart(String
the part name
name
,
String
the part fileName
fileName
,
HttpFields
the part headers
headers
)

Implements abstract org.eclipse.jetty.http.MultiPart.AbstractPartsListener.onPart.

Callback method invoked when a Part has been parsed.

public void
onPartContent(Content.Chunk
the part content chunk
chunk
)

Overrides default org.eclipse.jetty.http.MultiPart.Parser.Listener.onPartContent.

Callback method invoked when a part content Chunk has been parsed.

Inherited from org.eclipse.jetty.http.MultiPart.AbstractPartsListener:
getFileNamegetNameonPartEndonPartHeader

Field Detail

failureback to summary
private Throwable failure
lockback to summary
private final AutoLock lock
partChunksback to summary
private final List<Content.Chunk> partChunks
partsback to summary
private final List<MultiPart.Part> parts

Constructor Detail

PartsListenerback to summary
private PartsListener()

Method Detail

failback to summary
private void fail(Throwable cause)
isFailedback to summary
private boolean isFailed()
onCompleteback to summary
public void onComplete()

Overrides default org.eclipse.jetty.http.MultiPart.Parser.Listener.onComplete.

Doc from org.eclipse.jetty.http.MultiPart.Parser.Listener.onComplete.

Callback method invoked when the whole multipart content has been parsed.

Annotations
@Override
onFailureback to summary
public void onFailure(Throwable failure)

Overrides default org.eclipse.jetty.http.MultiPart.Parser.Listener.onFailure.

Doc from org.eclipse.jetty.http.MultiPart.Parser.Listener.onFailure.

Callback method invoked when the parser cannot parse the multipart content.

Parameters
failure:Throwable

the failure cause

Annotations
@Override
onPartback to summary
public void onPart(String name, String fileName, HttpFields headers)

Implements abstract org.eclipse.jetty.http.MultiPart.AbstractPartsListener.onPart.

Doc from org.eclipse.jetty.http.MultiPart.AbstractPartsListener.onPart.

Callback method invoked when a Part has been parsed.

Parameters
name:String

the part name

fileName:String

the part fileName

headers:HttpFields

the part headers

Annotations
@Override
onPartContentback to summary
public void onPartContent(Content.Chunk chunk)

Overrides default org.eclipse.jetty.http.MultiPart.Parser.Listener.onPartContent.

Doc from org.eclipse.jetty.http.MultiPart.Parser.Listener.onPartContent.

Callback method invoked when a part content Chunk has been parsed.

The Chunk must be Content.Chunk#retain() retained} if it not consumed by this method (for example, stored away for later use).

Parameters
chunk:Content.Chunk

the part content chunk

Annotations
@Override
org.eclipse.jetty.http back to summary

public Class MultiPartByteRanges.Part

extends Part
Class Inheritance

A MultiPart.Part whose content is a byte range of a Resource.

Field Summary

Modifier and TypeField and Description
private final ByteRange
private final Resource
Inherited from org.eclipse.jetty.http.MultiPart.Part:
CLOSE_EXCEPTION

Constructor Summary

AccessConstructor and Description
public
Part(String contentType, Resource resource, ByteRange byteRange, long contentLength)

public
Part(HttpFields headers, Resource resource, ByteRange byteRange)

Method Summary

Modifier and TypeMethod and Description
public Content.Source
newContentSource()

Implements abstract org.eclipse.jetty.http.MultiPart.Part.newContentSource.

Returns the content of this part as a new Content.Source

If the content is reproducible, invoking this method multiple times will return a different independent instance for every invocation.

Inherited from org.eclipse.jetty.http.MultiPart.Part:
closedeletefailgetContentAsStringgetContentSourcegetFileNamegetHeadersgetLengthgetNamewriteTo

Field Detail

byteRangeback to summary
private final ByteRange byteRange
resourceback to summary
private final Resource resource

Constructor Detail

Partback to summary
public Part(String contentType, Resource resource, ByteRange byteRange, long contentLength)
Partback to summary
public Part(HttpFields headers, Resource resource, ByteRange byteRange)

Method Detail

newContentSourceback to summary
public Content.Source newContentSource()

Implements abstract org.eclipse.jetty.http.MultiPart.Part.newContentSource.

Doc from org.eclipse.jetty.http.MultiPart.Part.newContentSource.

Returns the content of this part as a new Content.Source

If the content is reproducible, invoking this method multiple times will return a different independent instance for every invocation.

If the content is not reproducible, subsequent calls to this method will return null.

The content type and content encoding are specified in this part's headers.

The content encoding may be specified by the part named _charset_, as specified in RFC 7578, section 4.6.

Returns:Content.Source

the content of this part as a new Content.Source or null if the content cannot be consumed multiple times.

Annotations
@Override
org.eclipse.jetty.http back to summary

public Class MultiPartByteRanges.Parts

extends Object
implements Iterable<MultiPart.Part>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable

An ordered list of MultiPart.Parts that can be accessed by index, or iterated over.

Field Summary

Modifier and TypeField and Description
private final String
private final List<MultiPart.Part>

Constructor Summary

AccessConstructor and Description
private
Parts(String boundary, List<MultiPart.Part> parts)

Method Summary

Modifier and TypeMethod and Description
public MultiPart.Part

Returns:

the MultiPart.Part at the given index
get
(int
the index of the MultiPart.Part to return
index
)

Returns the MultiPart.Part at the given index, a number between 0 included and the value returned by size() excluded.

public String

Returns:

the boundary string
getBoundary
()

public Iterator<MultiPart.Part>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public int

Returns:

the number of parts
size
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundaryback to summary
private final String boundary
partsback to summary
private final List<MultiPart.Part> parts

Constructor Detail

Partsback to summary
private Parts(String boundary, List<MultiPart.Part> parts)

Method Detail

getback to summary
public MultiPart.Part get(int index)

Returns the MultiPart.Part at the given index, a number between 0 included and the value returned by size() excluded.

Parameters
index:int

the index of the MultiPart.Part to return

Returns:MultiPart.Part

the MultiPart.Part at the given index

getBoundaryback to summary
public String getBoundary()
Returns:String

the boundary string

iteratorback to summary
public Iterator<MultiPart.Part> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<MultiPart.Part>

an Iterator.

Annotations
@Override
sizeback to summary
public int size()
Returns:int

the number of parts

See Also
get(int)
org.eclipse.jetty.http back to summary

public Class MultiPartByteRanges.PathContentSource

extends PathContentSource
Class Inheritance

A specialized org.eclipse.jetty.io.content.PathContentSource whose content is sliced by a byte range.

Field Summary

Modifier and TypeField and Description
private final ByteRange
private long

Constructor Summary

AccessConstructor and Description
public
PathContentSource(Path path, ByteRange byteRange)

Method Summary

Modifier and TypeMethod and Description
protected boolean
protected SeekableByteChannel
protected int
Inherited from org.eclipse.jetty.io.content.PathContentSource:
demandfailgetBufferSizegetLengthgetPathisUseDirectByteBuffersreadrewindsetBufferSizesetUseDirectByteBuffers

Field Detail

byteRangeback to summary
private final ByteRange byteRange
toReadback to summary
private long toRead

Constructor Detail

PathContentSourceback to summary
public PathContentSource(Path path, ByteRange byteRange)

Method Detail

isReadCompleteback to summary
protected boolean isReadComplete(long read)

Overrides org.eclipse.jetty.io.content.PathContentSource.isReadComplete.

Annotations
@Override
openback to summary
protected SeekableByteChannel open() throws IOException

Overrides org.eclipse.jetty.io.content.PathContentSource.open.

Annotations
@Override
readback to summary
protected int read(SeekableByteChannel channel, ByteBuffer byteBuffer) throws IOException

Overrides org.eclipse.jetty.io.content.PathContentSource.read.

Annotations
@Override