mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
Improve API
Signed-off-by: Michal Michalowski <michal.michalowski@openet.com>
This commit is contained in:
@@ -277,15 +277,15 @@ class Http2ClientConnection extends Http2ConnectionBase implements HttpClientCon
|
||||
|
||||
@Override
|
||||
void handlePriorityChange(StreamPriority streamPriority) {
|
||||
if(streamPriority != null && !streamPriority.equals(streamPriority())) {
|
||||
setStreamPriority(streamPriority);
|
||||
if(streamPriority != null && !streamPriority.equals(priority())) {
|
||||
priority(streamPriority);
|
||||
response.handlePriorityChange(streamPriority);
|
||||
}
|
||||
}
|
||||
|
||||
void handleHeaders(Http2Headers headers, StreamPriority streamPriority, boolean end) {
|
||||
if(streamPriority != null)
|
||||
setStreamPriority(streamPriority);
|
||||
priority(streamPriority);
|
||||
if (response == null || response.statusCode() == 100) {
|
||||
int status;
|
||||
String statusMessage;
|
||||
@@ -363,7 +363,7 @@ class Http2ClientConnection extends Http2ConnectionBase implements HttpClientCon
|
||||
if (conn.metrics != null) {
|
||||
request.metric(conn.metrics.requestBegin(conn.queueMetric, conn.metric(), conn.localAddress(), conn.remoteAddress(), request));
|
||||
}
|
||||
setStreamPriority(streamPriority);
|
||||
priority(streamPriority);
|
||||
writeHeaders(h, end && content == null);
|
||||
if (content != null) {
|
||||
writeBuffer(content, end);
|
||||
@@ -388,8 +388,8 @@ class Http2ClientConnection extends Http2ConnectionBase implements HttpClientCon
|
||||
|
||||
|
||||
@Override
|
||||
public void updateStreamPriority(StreamPriority streamPriority) {
|
||||
setStreamPriority(streamPriority);
|
||||
public void updatePriority(StreamPriority streamPriority) {
|
||||
priority(streamPriority);
|
||||
writePriorityFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class Http2ServerConnection extends Http2ConnectionBase {
|
||||
return;
|
||||
}
|
||||
Http2ServerRequestImpl req = createRequest(streamId, headers);
|
||||
req.setStreamPriority(new StreamPriority(streamDependency, weight, exclusive));
|
||||
req.priority(new StreamPriority(streamDependency, weight, exclusive));
|
||||
|
||||
stream = req;
|
||||
CharSequence value = headers.get(HttpHeaderNames.EXPECT);
|
||||
@@ -184,7 +184,7 @@ public class Http2ServerConnection extends Http2ConnectionBase {
|
||||
Http2Stream promisedStream = handler.connection().stream(promisedStreamId);
|
||||
boolean writable = handler.encoder().flowController().isWritable(promisedStream);
|
||||
Push push = new Push(promisedStream, contentEncoding, method, path, writable, completionHandler);
|
||||
push.setStreamPriority(streamPriority);
|
||||
push.priority(streamPriority);
|
||||
streams.put(promisedStreamId, push);
|
||||
if (maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) {
|
||||
concurrentStreams++;
|
||||
|
||||
@@ -536,7 +536,7 @@ public class Http2ServerRequestImpl extends VertxHttp2Stream<Http2ServerConnecti
|
||||
synchronized (conn) {
|
||||
handler = streamPriorityHandler;
|
||||
if(streamPriority != null && !streamPriority.equals(streamPriority())) {
|
||||
setStreamPriority(streamPriority);
|
||||
priority(streamPriority);
|
||||
priorityChanged = true;
|
||||
}
|
||||
}
|
||||
@@ -545,4 +545,11 @@ public class Http2ServerRequestImpl extends VertxHttp2Stream<Http2ServerConnecti
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamPriority streamPriority() {
|
||||
return priority();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ public class Http2ServerResponseImpl implements HttpServerResponse {
|
||||
throw new IllegalStateException("A push response cannot promise another push");
|
||||
}
|
||||
checkEnded();
|
||||
conn.sendPush(stream.id(), host, method, headers, path, stream.streamPriority(), handler);
|
||||
conn.sendPush(stream.id(), host, method, headers, path, stream.priority(), handler);
|
||||
if (!inHandler) {
|
||||
ctx.flush();
|
||||
}
|
||||
@@ -715,8 +715,8 @@ public class Http2ServerResponseImpl implements HttpServerResponse {
|
||||
|
||||
@Override
|
||||
public HttpServerResponse setStreamPriority(StreamPriority streamPriority) {
|
||||
if(!streamPriority.equals(stream.streamPriority())) {
|
||||
stream.setStreamPriority(streamPriority);
|
||||
if(!streamPriority.equals(stream.priority())) {
|
||||
stream.priority(streamPriority);
|
||||
if(headWritten) {
|
||||
stream.writePriorityFrame();
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ public class HttpClientRequestImpl extends HttpClientRequestBase implements Http
|
||||
if(!streamPriority.equals(getStreamPriority())) {
|
||||
this.streamPriority = streamPriority;
|
||||
if(stream != null) {
|
||||
stream.updateStreamPriority(streamPriority);
|
||||
stream.updatePriority(streamPriority);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -693,6 +693,6 @@ public class HttpClientRequestImpl extends HttpClientRequestBase implements Http
|
||||
public StreamPriority getStreamPriority() {
|
||||
// If stream was already created return the priority value from the stream
|
||||
HttpClientStream s = stream;
|
||||
return s != null ? s.streamPriority() : streamPriority;
|
||||
return s != null ? s.priority() : streamPriority;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class HttpClientResponseImpl implements HttpClientResponse {
|
||||
@Override
|
||||
public StreamPriority streamPriority() {
|
||||
synchronized (conn) {
|
||||
return stream.streamPriority();
|
||||
return stream.priority();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ interface HttpClientStream {
|
||||
|
||||
NetSocket createNetSocket();
|
||||
|
||||
default StreamPriority streamPriority() {
|
||||
default StreamPriority priority() {
|
||||
return null;
|
||||
}
|
||||
default void updateStreamPriority(StreamPriority streamPriority) { }
|
||||
default void updatePriority(StreamPriority streamPriority) { }
|
||||
}
|
||||
@@ -163,11 +163,11 @@ abstract class VertxHttp2Stream<C extends Http2ConnectionBase> {
|
||||
void handleClose() {
|
||||
}
|
||||
|
||||
public void setStreamPriority(StreamPriority streamPriority) {
|
||||
public void priority(StreamPriority streamPriority) {
|
||||
this.streamPriority = streamPriority;
|
||||
}
|
||||
|
||||
public StreamPriority streamPriority() {
|
||||
public StreamPriority priority() {
|
||||
return streamPriority;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user