wangzihaogithub / spring-boot-protocol Goto Github PK
View Code? Open in Web Editor NEWspringboot功能扩充-netty动态协议,可以支持各种网络协议的动态切换(单端口支持多个网络协议).支持mmap,sendfile零拷贝,http请求批量聚合
Home Page: https://zihaoapi.cn
License: Apache License 2.0
springboot功能扩充-netty动态协议,可以支持各种网络协议的动态切换(单端口支持多个网络协议).支持mmap,sendfile零拷贝,http请求批量聚合
Home Page: https://zihaoapi.cn
License: Apache License 2.0
Great job!
Is it possible to split the code into core module plus protocol modules (servlet, mqtt...) and
auto loading the protocol modules when application startup depending on protocol modules dependency involved.
And is there embeded support for http file server besides servlet.
当我在上传大文件的时候会发生OOM
下面是文件上传代码:
`
@RequestMapping(value = "/stream-upload-test")
public ResponseEntity<String> upload(HttpServletRequest request, HttpServletResponse response)
throws IOException, FileUploadException {
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (isMultipart) {
ServletFileUpload upload = new ServletFileUpload();
Map<String, String> params = new HashMap<>();
InputStream is = null;
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
FileItemStream item = iter.next();
if (!item.isFormField()) {
is = item.openStream();
try {
int i = 0;
byte bb [] = new byte[4096];
while((i = is.read(bb)) != -1){
System.out.println(Arrays.toString(bb));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != is) {
is.close();
}
}
} else {
String fieldName = item.getFieldName();
String value = Streams.asString(item.openStream());
System.out.println(fieldName + " : " + value);
}
}
}
return new ResponseEntity<String>(HttpStatus.OK);
}
`
Solon 的仓库在这儿:https://github.com/noear/solon
Hi, Zihao。在试用websocket功能的时候,直接运行https://github.com/wangzihaogithub/spring-netty-example/tree/master/netty-example-websocket-server,
发现客户端连接websocket服务端的时候,一直处于pending的状态,无法连接成功。
你的单元测试中没有关于206的代码.
你实现的http在此处表现地有些奇怪.
我的认知,
在http-nio背景下, servlet.NettyOutputStream.write(filechannel, offset, limit), channel代表了bodyStream. 客户端按自己需求对bodyStream做读取,
实操现象,
在chrome控制台观察由video引发的请求, size和time的数值是不正常的, 随着time增大, size不变, 虽然可以正常播放, 进度条亦不受影响可以拖动,
同时发现resp.setHeader("Connection","keep-alive")是无效的, 断点了一下发现当exchange支持keep-alive时, 会忽略nettyHeaders中的keep-alvie头,
你有什么头绪吗.
在此处回复你在上一个issue中的邀请, 我对git pull request的流程并不熟悉, 我会尝试去做的.
我希望你能建立一个该项目专属的qq群, 如果可以的话.
像这个问题, 我可以把我的206实现, 和另一个206表现正常的httpserver的代码发群里, 你得空也方便查阅.
对于name以$开头的cookie会报错,这个和tomcat稍有区别
原因如下:
在servlet里,cookie的规范如下
if (!isToken(name) ||
name.equalsIgnoreCase("Comment") || // rfc2019
name.equalsIgnoreCase("Discard") || // 2019++
name.equalsIgnoreCase("Domain") ||
name.equalsIgnoreCase("Expires") || // (old cookies)
name.equalsIgnoreCase("Max-Age") || // rfc2019
name.equalsIgnoreCase("Path") ||
name.equalsIgnoreCase("Secure") ||
name.equalsIgnoreCase("Version") ||
name.startsWith("$")) {
但是在tomcat里,cookie的实现并没有按照servlet的逻辑去做,而是自己实现的,仅仅做了长度验证,如下:
public Cookie(String name, String value) {
validation.validate(name);
this.name = name;
this.value = value;
}
class CookieNameValidator {
private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
protected static final ResourceBundle lStrings = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
protected final BitSet allowed = new BitSet(128);
protected CookieNameValidator(String separators) {
this.allowed.set(32, 127);
for(int i = 0; i < separators.length(); ++i) {
char ch = separators.charAt(i);
this.allowed.clear(ch);
}
}
void validate(String name) {
if (name != null && name.length() != 0) {
if (!this.isToken(name)) {
String errMsg = lStrings.getString("err.cookie_name_is_token");
throw new IllegalArgumentException(MessageFormat.format(errMsg, name));
}
} else {
throw new IllegalArgumentException(lStrings.getString("err.cookie_name_blank"));
}
}
private boolean isToken(String possibleToken) {
int len = possibleToken.length();
for(int i = 0; i < len; ++i) {
char c = possibleToken.charAt(i);
if (!this.allowed.get(c)) {
return false;
}
}
return true;
}
}
ServletHttpServletRequest#newSessionId
, SNOWFLAKE_ID_WORKER always execute.
HttpServletProtocolSpringAdapter中根据multipart大小设置HttpObjectAggregator的maxContentLength,当文件大小限制超过2G,由于强制转换导致HttpObjectAggregator的maxContentLength值被设置为0。
ERROR 8220 --- [-Worker-NIO-3-3] c.g.n.p.servlet.ServletChannelHandler : java.lang.ClassCastException: javax.servlet.http.Cookie cannot be cast to java.lang.Comparable
[NettyX-Server-Worker-Epoll-4-4] c.g.n.p.s.DispatcherChannelHandler : handler exception. case=io.netty.channel.unix.Errors$NativeIoException: recvAddress(..) failed: Connection reset by peer, channel=[id: 0xd09192e2, L:/192.123.1.78:5783 - R:/192.168.90.187:56221]
可以讲讲servlet这块儿的转发以及兼容实现吗?
我看了servlet的代码太多了,尴尬
你好,为什么说用了线程池来执行http runnable
比只用event loop
的qps 高?
我以为,把http runnable
提交到线程池就是直接返回了,然后继续提交下一个http runnable
,应该更高?
在NettyMessageToServletRunnable里面先处理HttpRequest,在处理HttpContent。当msg是DefaultFullHttpRequest时会被忽略掉HttpConetnt导致不能正常处理请求
包import io.netty.bootstrap.ChannelFactory;
已经过期
正确的应该是 import io.netty.channel.ChannelFactory;
比如反序列化漏洞?
环境:springboot2.7.18
请问如何初始化ServletContext 中的resourceManager呢?
让他读取static、template资源文件夹,谢谢
详见org.springframework.web.socket.server.support.AbstractHandshakeHandler#initRequestUpgradeStrategy,
当我排除spring-boot-starter-web对tomcat-starter的依赖, websocket便无法成功适配
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.