Skip to content

Commit

Permalink
Merge branch 'release/0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mostroverkhov committed Aug 19, 2020
2 parents 0c78397 + 26fac2b commit 961c3b7
Show file tree
Hide file tree
Showing 24 changed files with 2,430 additions and 174 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://travis-ci.org/jauntsdn/netty-websocket-http2.svg?branch=develop)](https://travis-ci.org/jauntsdn/netty-websocket-http2)
![Maven Central](https://img.shields.io/maven-central/v/com.jauntsdn.netty/netty-websocket-http2)

# netty-websocket-http2

Expand All @@ -8,7 +9,7 @@ Library is addressing 2 use cases: for application servers and clients,
It is transparent use of existing http1 websocket handlers on top of http2 streams; for gateways/proxies,
It is websockets-over-http2 support with no additional dependencies and minimal overhead.

[https://jauntsdn.com/post/netty-websockets-over-http2/](https://jauntsdn.com/post/netty-websockets-over-http2/)
[https://jauntsdn.com/post/netty-websocket-http2/](https://jauntsdn.com/post/netty-websocket-http2/)

### websocket channel API
Intended for application servers and clients.
Expand Down
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ subprojects {
api "org.slf4j:slf4j-api"
testImplementation "org.assertj:assertj-core"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
testImplementation "org.junit.jupiter:junit-jupiter-params"
testRuntimeOnly "ch.qos.logback:logback-classic"
}

repositories {
mavenCentral()
mavenLocal()
}

plugins.withType(JavaPlugin) {
Expand All @@ -70,6 +70,7 @@ subprojects {
}

test {
useJUnitPlatform()
testLogging {
events "failed"
exceptionFormat "full"
Expand Down Expand Up @@ -127,4 +128,6 @@ def projectVersion(project) {
}
}
return project.version + versionSuffix
}
}

defaultTasks 'clean', 'build'
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.jauntsdn.netty
version=0.0.1
version=0.0.2

googleJavaFormatPluginVersion=0.9
dependencyManagementPluginVersion=1.0.9.RELEASE
Expand Down
5 changes: 5 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
subprojects {

tasks.withType(GenerateModuleMetadata) {
enabled = false
}

plugins.withType(MavenPublishPlugin) {
publishing {
publications {
Expand Down
1 change: 1 addition & 0 deletions netty-websocket-http2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ description = "Netty based implementation of rfc8441 - bootstrapping websockets
dependencies {
api "io.netty:netty-codec-http2"
compileOnly "com.google.code.findbugs:jsr305"
testRuntimeOnly "io.netty:netty-tcnative-boringssl-static"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ io.netty:netty-codec:4.1.51.Final
io.netty:netty-common:4.1.51.Final
io.netty:netty-handler:4.1.51.Final
io.netty:netty-resolver:4.1.51.Final
io.netty:netty-tcnative-boringssl-static:2.0.31.Final
io.netty:netty-transport:4.1.51.Final
org.apiguardian:apiguardian-api:1.1.0
org.assertj:assertj-core:3.16.1
org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.jupiter:junit-jupiter-params:5.6.2
org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.2
org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0
org.slf4j:slf4j-api:1.7.30
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2020 - present Maksym Ostroverkhov.
*
* Licensed 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
*
* http://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 com.jauntsdn.netty.handler.codec.http2.websocketx;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http2.Http2Exception;
import io.netty.handler.codec.http2.Http2Flags;
import io.netty.handler.codec.http2.Http2FrameAdapter;
import io.netty.handler.codec.http2.Http2FrameListener;

interface Http2WebSocket extends Http2FrameListener {

void trySetWritable();

void fireExceptionCaught(Throwable t);

void streamClosed();

void closeForcibly();

Http2WebSocket CLOSED = new Http2WebSocketClosedChannel();

class Http2WebSocketClosedChannel extends Http2FrameAdapter implements Http2WebSocket {

@Override
public void streamClosed() {}

@Override
public void trySetWritable() {}

@Override
public void fireExceptionCaught(Throwable t) {}

@Override
public void closeForcibly() {}

@Override
public int onDataRead(
ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream)
throws Http2Exception {
int processed = super.onDataRead(ctx, streamId, data, padding, endOfStream);
data.release();
return processed;
}

@Override
public void onUnknownFrame(
ChannelHandlerContext ctx,
byte frameType,
int streamId,
Http2Flags flags,
ByteBuf payload) {
payload.release();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ public interface Http2WebSocketAcceptor {
default boolean writesResponseHeaders() {
return true;
}

Http2WebSocketAcceptor ACCEPT_ALL =
new Http2WebSocketAcceptor() {

@Override
public ChannelFuture accept(
ChannelHandlerContext context, Http2Headers request, Http2Headers response) {
return context.newSucceededFuture();
}

@Override
public boolean writesResponseHeaders() {
return false;
}
};
}
Loading

0 comments on commit 961c3b7

Please sign in to comment.