forked from java-native-access/jna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for QuicStreamFrame (java-native-access#62)
Motivation: For a lot of use-cases just using ByteBuf on top of the QuicStreamChannel is good enough. That said there are situations where a user may want to have some more control about when the FIN is sent etc. For this cases we should directly support QuicStreamFrame which basically wraps a ByteBuf but also allows to specify if a FIN flag should be send or not. Beside this the user may want to also receive QuicStreamFrame's directly and so have fine grained control Modifications: - Add QuicStreamFrame and a default implementation - Add support to write QuicStreamFrame - Add support to directly read QuichStreamFrame and fire these through the pipeline. This needs to be enabled by the user via a configuration option and is not the default. - Add new ChannelOption and setter / getter to enable reading frames to QuicStreamChannel - Let QuicStreamChannel.config() return QuicStreamChannelConfig - Add unit tests Result: More flexible usage of QUIC codec possible
- Loading branch information
1 parent
cb206a5
commit 61ac022
Showing
9 changed files
with
421 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/io/netty/incubator/codec/quic/DefaultQuicStreamFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2020 The Netty Project | ||
* | ||
* The Netty Project licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.netty.incubator.codec.quic; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.DefaultByteBufHolder; | ||
|
||
public final class DefaultQuicStreamFrame extends DefaultByteBufHolder implements QuicStreamFrame { | ||
|
||
private final boolean fin; | ||
|
||
public DefaultQuicStreamFrame(ByteBuf data, boolean fin) { | ||
super(data); | ||
this.fin = fin; | ||
} | ||
|
||
@Override | ||
public boolean hasFin() { | ||
return fin; | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame copy() { | ||
return new DefaultQuicStreamFrame(content().copy(), fin); | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame duplicate() { | ||
return new DefaultQuicStreamFrame(content().duplicate(), fin); | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame retainedDuplicate() { | ||
return new DefaultQuicStreamFrame(content().retainedDuplicate(), fin); | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame replace(ByteBuf content) { | ||
return new DefaultQuicStreamFrame(content, fin); | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame retain() { | ||
super.retain(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame retain(int increment) { | ||
super.retain(increment); | ||
return this; | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame touch() { | ||
super.touch(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public QuicStreamFrame touch(Object hint) { | ||
super.touch(hint); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/io/netty/incubator/codec/quic/QuicStreamFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2020 The Netty Project | ||
* | ||
* The Netty Project licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.netty.incubator.codec.quic; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.ByteBufHolder; | ||
|
||
/** | ||
* A QUIC STREAM_FRAME. | ||
*/ | ||
public interface QuicStreamFrame extends ByteBufHolder { | ||
|
||
/** | ||
* Returns {@code true} if the frame has the FIN set, which means it notifies the remote peer that | ||
* there will be no more writing happen. {@code false} otherwise. | ||
*/ | ||
boolean hasFin(); | ||
|
||
@Override | ||
QuicStreamFrame copy(); | ||
|
||
@Override | ||
QuicStreamFrame duplicate(); | ||
|
||
@Override | ||
QuicStreamFrame retainedDuplicate(); | ||
|
||
@Override | ||
QuicStreamFrame replace(ByteBuf content); | ||
|
||
@Override | ||
QuicStreamFrame retain(); | ||
|
||
@Override | ||
QuicStreamFrame retain(int increment); | ||
|
||
@Override | ||
QuicStreamFrame touch(); | ||
|
||
@Override | ||
QuicStreamFrame touch(Object hint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.