# tomcat-lite **Repository Path**: alpha-99/tomcat-lite ## Basic Information - **Project Name**: tomcat-lite - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-05 - **Last Updated**: 2024-12-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### Servlet规范中Request的Header中Set-Cookie需要满足下面的格式,任选一种即可 + Set-Cookie: = + Set-Cookie: =; Expires= + Set-Cookie: =; Max-Age= + Set-Cookie: =; Domain= + Set-Cookie: =; Path= + Set-Cookie: =; Secure 当前环境选择比较简单的,第一种key=value的方式。 ### transfer-encoding 格式: ```text 分块的长度 —— chunk size | CRLF 分块的数据 —— chunk data | CRLF 分块的长度 —— chunk size | CRLF 分块的数据 —— chunk data | CRLF …… // 此处省略 分块的长度 —— chunk size | CRLF 分块的数据 —— chunk data | CRLF 分块的长度 —— 0 | CRLF 结束标识符 —— CRLF ``` 1. 编码是由若干个块组成,由一个标明长度为0的块结束,也就是说,检测到 `chunk size = 0` 表示数据流已传输完毕。 2. 每个chunk有两部分组成,第一部分是这个分块的长度,第二部分则是前一部分指定长度对应的内容,每个部分用CRLF换行符隔开。 3. 结束时只标识CRLF。 响应包示例 ```HTTP/1.1 200 OK Content-Type: text/plain Transfer-Encoding: chunked 35 This is the data in the first chunk 26 and this is the second one 3 con 8 sequence 0 ``` ### 测试的URL ```curl -X POST http://localhost:8080/servlet/test.TestServlet \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Content-Length: 8" \ -d "name=bhl" curl -X POST http://localhost:8080/servlet/test.TestServlet \ -H "Content-Type: application/json" \ -H "Content-Length: 14" \ -d {"name":"bhl"} POST /servlet/test.TestServlet Host: localhost:8080 Content-Type: application/x-www-form-urlencoded Cookie: jsessionid=DJSKAJLDKSLADKLAS;userId=123 Content-Length: 9 name=haha ```