Coder Social home page Coder Social logo

wangzihaogithub / spring-boot-protocol Goto Github PK

View Code? Open in Web Editor NEW
115.0 4.0 60.0 2.55 MB

springboot功能扩充-netty动态协议,可以支持各种网络协议的动态切换(单端口支持多个网络协议).支持mmap,sendfile零拷贝,http请求批量聚合

Home Page: https://zihaoapi.cn

License: Apache License 2.0

Java 99.54% HTML 0.46%
spring-boot protocol rpc mqtt servlet springcloud springservlet spring-boot-protocol netty

spring-boot-protocol's People

Contributors

dependabot[bot] avatar wangzihaogithub avatar wenjieyin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spring-boot-protocol's Issues

split to core module plus protocol modules

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.

FileUpload OutOfDirectMemoryError

当我在上传大文件的时候会发生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);
}

`

错误信息截图如下:
image

有关206状态码, PARTIAL_CONTENT的行为

你的单元测试中没有关于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的代码发群里, 你得空也方便查阅.

Cookie name \"{0}\" is a reserved token

对于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;
}

}

superfluous code

ServletHttpServletRequest#newSessionId, SNOWFLAKE_ID_WORKER always execute.

spring-netty-example 请求出现异常

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

servlet mapping

可以讲讲servlet这块儿的转发以及兼容实现吗?
我看了servlet的代码太多了,尴尬

关于线程池,大佬求解答。。

你好,为什么说用了线程池来执行http runnable比只用event loop 的qps 高?

我以为,把http runnable提交到线程池就是直接返回了,然后继续提交下一个http runnable,应该更高?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.