Top Description Fields Constructors Methods
io.netty.contrib.handler.codec.http.multipart

public abstract Class AbstractHttpData

extends ResourceSupport<HttpData, AbstractHttpData>
implements HttpData
Class Inheritance
All Implemented Interfaces
io.netty.contrib.handler.codec.http.multipart.HttpData, io.netty.contrib.handler.codec.http.multipart.InterfaceHttpData, io.netty5.util.Resource, java.lang.AutoCloseable, java.lang.Comparable
Known Direct Subclasses
io.netty.contrib.handler.codec.http.multipart.AbstractMemoryHttpData, io.netty.contrib.handler.codec.http.multipart.AbstractDiskHttpData
Imports
io.netty5.buffer.Buffer, .Drop, io.netty5.buffer.internal.ResourceSupport, io.netty5.channel.ChannelException, io.netty5.handler.codec.http.HttpConstants, io.netty5.util.internal.ObjectUtil, io.netty.contrib.handler.codec.http.multipart.Helpers.ThrowingConsumer, java.io.IOException, java.nio.charset.Charset, java.util.regex.Pattern

Abstract HttpData implementation

Field Summary

Modifier and TypeField and Description
private Charset
private boolean
protected long
private static final Drop<AbstractHttpData>
protected static final byte[]
private long
private final String
private static final Pattern
protected long
private static final Pattern

Constructor Summary

AccessConstructor and Description
protected
AbstractHttpData(String name, Charset charset, long size)

protected

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
public void
checkSize(long newSize)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.checkSize.

Check if the new size is not reaching the max limit allowed.
protected RuntimeException
public long
definedLength()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.definedLength.

Returns the defined length of the HttpData.
public Charset
getCharset()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getCharset.

Returns the Charset passed by the browser or null if not defined.
public long
getMaxSize()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getMaxSize.

Returns the maxSize for this HttpData.
public String
getName()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpData.getName.

Returns the name of this InterfaceHttpData.
public boolean
public long
length()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.length.

Returns the size in byte of the InterfaceHttpData
public void
setCharset(Charset
Charset to set - must be not null
charset
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setCharset.

Set the Charset passed by the browser if defined
protected void
protected void
setCompleted(boolean completed)

public void
setMaxSize(long maxSize)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setMaxSize.

Set the maxSize for this HttpData.
public <E extends Exception> void
usingContent(Helpers.ThrowingConsumer<Buffer, E>
The file item buffer callback
callback
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.usingContent.

Calls the passed callback to operate on the file item as a Buffer.
Inherited from io.netty5.buffer.internal.ResourceSupport:
acquireattachTraceclosecountBorrowsisAccessibleisOwnedmakeInaccessiblenotSendableExceptionprepareSendsendtouchunsafeGetDropunsafeSetDrop

Field Detail

charsetback to summary
private Charset charset
completedback to summary
private boolean completed
definedSizeback to summary
protected long definedSize
dropback to summary
private static final Drop<AbstractHttpData> drop

Hides io.netty5.buffer.internal.ResourceSupport.drop.

EMPTY_ARRAYback to summary
protected static final byte[] EMPTY_ARRAY
maxSizeback to summary
private long maxSize
nameback to summary
private final String name
REPLACE_PATTERNback to summary
private static final Pattern REPLACE_PATTERN
sizeback to summary
protected long size
STRIP_PATTERNback to summary
private static final Pattern STRIP_PATTERN

Constructor Detail

AbstractHttpDataback to summary
protected AbstractHttpData(String name, Charset charset, long size)
AbstractHttpDataback to summary
protected AbstractHttpData(AbstractHttpData copy)

Method Detail

checkAccessibleback to summary
protected void checkAccessible()
checkAccessibleback to summary
protected void checkAccessible(Buffer cleanup)
checkSizeback to summary
public void checkSize(long newSize) throws IOException

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.checkSize.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.checkSize.

Check if the new size is not reaching the max limit allowed. The limit is always computed in terms of bytes.

Annotations
@Override
createResourceClosedExceptionback to summary
protected RuntimeException createResourceClosedException()

Implements abstract io.netty5.buffer.internal.ResourceSupport.createResourceClosedException.

Annotations
@Override
definedLengthback to summary
public long definedLength()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.definedLength.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.definedLength.

Returns the defined length of the HttpData. If no Content-Length is provided in the request, the defined length is always 0 (whatever during decoding or in final state). If Content-Length is provided in the request, this is this given defined length. This value does not change, whatever during decoding or in the final state. This method could be used for instance to know the amount of bytes transmitted for one particular HttpData, for example one FileUpload or any known big Attribute.

Returns:long

the defined length of the HttpData

Annotations
@Override
getCharsetback to summary
public Charset getCharset()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getCharset.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getCharset.

Returns the Charset passed by the browser or null if not defined.

Returns:Charset

the Charset passed by the browser or null if not defined.

Annotations
@Override
getMaxSizeback to summary
public long getMaxSize()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getMaxSize.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getMaxSize.

Returns the maxSize for this HttpData.

Annotations
@Override
getNameback to summary
public String getName()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpData.getName.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpData.getName.

Returns the name of this InterfaceHttpData.

Annotations
@Override
isCompletedback to summary
public boolean isCompleted()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.isCompleted.

Returns:boolean

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.isCompleted.

True if the InterfaceHttpData is completed (all data are stored)

Annotations
@Override
lengthback to summary
public long length()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.length.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.length.

Returns the size in byte of the InterfaceHttpData

Returns:long

the size of the InterfaceHttpData

Annotations
@Override
setCharsetback to summary
public void setCharset(Charset charset)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setCharset.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.setCharset.

Set the Charset passed by the browser if defined

Parameters
charset:Charset

Charset to set - must be not null

Annotations
@Override
setCompletedback to summary
protected void setCompleted()
setCompletedback to summary
protected void setCompleted(boolean completed)
setMaxSizeback to summary
public void setMaxSize(long maxSize)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setMaxSize.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.setMaxSize.

Set the maxSize for this HttpData. When limit will be reached, an exception will be raised. Setting it to (-1) means no limitation. By default, to be set from the HttpDataFactory.

Annotations
@Override
usingContentback to summary
public <E extends Exception> void usingContent(Helpers.ThrowingConsumer<Buffer, E> callback) throws ThrowingConsumer-:E

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.usingContent.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.usingContent.

Calls the passed callback to operate on the file item as a Buffer.

Note

this method will allocate a lot of memory, if the data is currently stored on the file system.

Buffer ownersip:

The ownership of the buffer passed to the callack is not transferred and remains to this HttpData interface.
  • for memory based http data, the internal buffer is directly passed to the callback.
  • for disk based http data, a copy of the file content is passed to the callback and is immediately closed once the callback returns.
Parameters
<E>
the type of the exception thrown by the callback
callback:Helpers.ThrowingConsumer<Buffer, E>

The file item buffer callback

Annotations
@Override