Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed Nov 3, 2024
1 parent ee31df7 commit 70a2ebc
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<packaging>pom</packaging>

<properties>
<smarthttp.version>1.6.0</smarthttp.version>
<smarthttp.version>1.6.1</smarthttp.version>
<smartservlet.version>2.2</smartservlet.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

/**
Expand Down Expand Up @@ -894,7 +895,84 @@ public CompletableFuture<Object> getCompletableFuture() {

@Override
public PushBuilder newPushBuilder() {
// return new PushBuilderImpl(this);
throw new UnsupportedOperationException();
org.smartboot.http.server.PushBuilder pushBuilder = request.newPushBuilder();
return new PushBuilder() {
@Override
public PushBuilder method(String method) {
pushBuilder.method(method);
return this;
}

@Override
public PushBuilder queryString(String queryString) {
pushBuilder.queryString(queryString);
return this;
}

@Override
public PushBuilder sessionId(String sessionId) {
throw new IllegalStateException();
}

@Override
public PushBuilder setHeader(String name, String value) {
pushBuilder.setHeader(name, value);
return this;
}

@Override
public PushBuilder addHeader(String name, String value) {
pushBuilder.addHeader(name, value);
return this;
}

@Override
public PushBuilder removeHeader(String name) {
pushBuilder.removeHeader(name);
return this;
}

@Override
public PushBuilder path(String path) {
pushBuilder.path(getContextPath() + "/" + path);
return this;
}

@Override
public void push() {
pushBuilder.push();
}

@Override
public String getMethod() {
return pushBuilder.getMethod();
}

@Override
public String getQueryString() {
return pushBuilder.getQueryString();
}

@Override
public String getSessionId() {
return pushBuilder.getSessionId();
}

@Override
public Set<String> getHeaderNames() {
return pushBuilder.getHeaderNames();
}

@Override
public String getHeader(String name) {
return pushBuilder.getHeader(name);
}

@Override
public String getPath() {
return pushBuilder.getPath();
}
};
// throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ServerContainer getWebSocketServerContainer() {

@Override
public void doHandle(WebSocketRequest request, WebSocketResponse response) {
Attachment attachment = ((WebSocketRequestImpl) request).getAttachment();
Attachment attachment = request.getAttachment();
WebsocketSession session = (WebsocketSession) attachment.get(WebsocketProvider.WEBSOCKET_SESSION_ATTACH_KEY);
try {
switch (request.getFrameOpcode()) {
Expand Down

0 comments on commit 70a2ebc

Please sign in to comment.