- 浏览: 2877237 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (2529)
- finance (1459)
- technology (218)
- life (343)
- play (150)
- technology-component (0)
- idea (6)
- house (74)
- health (75)
- work (32)
- joke (23)
- blog (1)
- amazing (13)
- important (22)
- study (13)
- Alternative (0)
- funny (8)
- stock_technology (12)
- business (16)
- car (21)
- decorate (4)
- basketball (2)
- English (16)
- banker (1)
- TheBest (1)
- sample (2)
- love (13)
- management (4)
最新评论
-
zhongmin2012:
BSM确实需要实践,标准ITIL服务流程支持,要做好,需要花费 ...
BSM实施之前做什么 -
shw340518:
提示楼主,有时间逻辑bug:是你妈二十那年写的 那会儿连你爹都 ...
80后辣妈给未来儿子的信~我的儿,你也给我记住了~~~ -
guoapeng:
有相关的文档吗?
it项目管理表格(包含146个DOC文档模板) -
solomon:
看到的都是 这种 CTRL+C 和 CTRL+V 的文章, ...
Designing a website with InfoGlue components -
wendal:
恩, 不错. 有参考价值
Designing a website with InfoGlue components
Http11Processor class是获得一个Http请求后就由这个class来进行处理,处理函数当然就是 process,然后将获得的inputstream 传递给 InternalInputBuffer class ,这个class 中存放了 所
信息等,InternalInputBuffer 将各个head信息分解后会 传递给 Request 对象,之后我们程序中的想要获得某个页面的信息就可以从 request对象中获得了。
J2ee 只是规定了 HttpServletRequest 所需要获得的一些配置参数,本来还想从j2ee5 sdk中获得 http head body的实现,搞了半天全是interface ,真正的实现是 放在 各个不同容器当中的,所以resin和tomcat或者其他web container 都可能不同。好了,
接下去把其中的宝藏挖出来把。
完成WVBAII项目的 server,汗就是为了不每次http请求都response,费那么经,要我写个 server。
有必要提一下实现InputBuffer 接口的class:
InternalAprInputBuffer 其方法
parseRequestLine()
parseHeader()
...
对HTTP Head 真正的进行了解析。
信息等,InternalInputBuffer 将各个head信息分解后会 传递给 Request 对象,之后我们程序中的想要获得某个页面的信息就可以从 request对象中获得了。
J2ee 只是规定了 HttpServletRequest 所需要获得的一些配置参数,本来还想从j2ee5 sdk中获得 http head body的实现,搞了半天全是interface ,真正的实现是 放在 各个不同容器当中的,所以resin和tomcat或者其他web container 都可能不同。好了,
接下去把其中的宝藏挖出来把。
完成WVBAII项目的 server,汗就是为了不每次http请求都response,费那么经,要我写个 server。
有必要提一下实现InputBuffer 接口的class:
InternalAprInputBuffer 其方法
parseRequestLine()
parseHeader()
...
对HTTP Head 真正的进行了解析。
java 代码
- /**
- * Process pipelined HTTP requests using the specified input and output
- * streams.
- *
- * @throws IOException error during an I/O operation
- */
- public boolean process(long socket)
- throws IOException {
- ThreadWithAttributes thrA=
- (ThreadWithAttributes)Thread.currentThread();
- RequestInfo rp = request.getRequestProcessor();
- thrA.setCurrentStage(endpoint, "parsing http request");
- rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);
- // Set the remote address
- remoteAddr = null;
- remoteHost = null;
- localAddr = null;
- localName = null;
- remotePort = -1;
- localPort = -1;
- // Setting up the socket
- this.socket = socket;
- inputBuffer.setSocket(socket);
- outputBuffer.setSocket(socket);
- // Error flag
- error = false;
- keepAlive = true;
- int keepAliveLeft = maxKeepAliveRequests;
- long soTimeout = endpoint.getSoTimeout();
- int limit = 0;
- if (endpoint.getFirstReadTimeout() > 0 || endpoint.getFirstReadTimeout() < -1) {
- limit = endpoint.getMaxThreads() / 2;
- }
- boolean keptAlive = false;
- boolean openSocket = false;
- while (started && !error && keepAlive) {
- // Parsing the request header
- try {
- if( !disableUploadTimeout && keptAlive && soTimeout > 0 ) {
- Socket.timeoutSet(socket, soTimeout * 1000);
- }
- if (!inputBuffer.parseRequestLine
- (keptAlive && (endpoint.getCurrentThreadsBusy() > limit))) {
- // This means that no data is available right now
- // (long keepalive), so that the processor should be recycled
- // and the method should return true
- openSocket = true;
- // Add the socket to the poller
- endpoint.getPoller().add(socket);
- break;
- }
- request.setStartTime(System.currentTimeMillis());
- thrA.setParam(endpoint, request.requestURI());
- keptAlive = true;
- if (!disableUploadTimeout) {
- Socket.timeoutSet(socket, timeout * 1000);
- }
- inputBuffer.parseHeaders();
- } catch (IOException e) {
- error = true;
- break;
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.header.parse"), t);
- }
- // 400 - Bad Request
- response.setStatus(400);
- error = true;
- }
- // Setting up filters, and parse some request headers
- thrA.setCurrentStage(endpoint, "prepareRequest");
- rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);
- try {
- prepareRequest();
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("http11processor.request.prepare"), t);
- }
- // 400 - Internal Server Error
- response.setStatus(400);
- error = true;
- }
- if (maxKeepAliveRequests > 0 && --keepAliveLeft == 0)
- keepAlive = false;
- // Process the request in the adapter
- if (!error) {
- try {
- thrA.setCurrentStage(endpoint, "service");
- rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
- adapter.service(request, response);
- // Handle when the response was committed before a serious
- // error occurred. Throwing a ServletException should both
- // set the status to 500 and set the errorException.
- // If we fail here, then the response is likely already
- // committed, so we can't try and set headers.
- if(keepAlive && !error) { // Avoid checking twice.
- error = response.getErrorException() != null ||
- statusDropsConnection(response.getStatus());
- }
- } catch (InterruptedIOException e) {
- error = true;
- } catch (Throwable t) {
- log.error(sm.getString("http11processor.request.process"), t);
- // 500 - Internal Server Error
- response.setStatus(500);
- error = true;
- }
- }
- // Finish the handling of the request
- try {
- thrA.setCurrentStage(endpoint, "endRequestIB");
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
- inputBuffer.endRequest();
- } catch (IOException e) {
- error = true;
- } catch (Throwable t) {
- log.error(sm.getString("http11processor.request.finish"), t);
- // 500 - Internal Server Error
- response.setStatus(500);
- error = true;
- }
- try {
- thrA.setCurrentStage(endpoint, "endRequestOB");
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
- outputBuffer.endRequest();
- } catch (IOException e) {
- error = true;
- } catch (Throwable t) {
- log.error(sm.getString("http11processor.response.finish"), t);
- error = true;
- }
- // If there was an error, make sure the request is counted as
- // and error, and update the statistics counter
- if (error) {
- response.setStatus(500);
- }
- request.updateCounters();
- thrA.setCurrentStage(endpoint, "ended");
- rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
- // Don't reset the param - we'll see it as ended. Next request
- // will reset it
- // thrA.setParam(null);
- // Next request
- inputBuffer.nextRequest();
- outputBuffer.nextRequest();
- // Do sendfile as needed: add socket to sendfile and end
- if (sendfileData != null) {
- sendfileData.socket = socket;
- sendfileData.keepAlive = keepAlive;
- if (!endpoint.getSendfile().add(sendfileData)) {
- openSocket = true;
- break;
- }
- }
- }
- rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
- // Recycle
- inputBuffer.recycle();
- outputBuffer.recycle();
- this.socket = 0;
- return openSocket;
- }
发表评论
-
New Enterprise Security Solutions
2011-09-13 15:46 0<!-- [if !mso]> <styl ... -
ES Announces Enterprise Security Solutions
2011-09-13 15:40 0<!-- [if !mso]> <styl ... -
linux下如何将文件打包、压缩并分割成制定大小?
2010-09-15 18:52 3269将大文件或目录打包、 ... -
rhel4 yum安装, 使用
2010-09-07 16:37 0第一种方法: yum源来自chinalinuxpub.com ... -
Windows: 远程自动安装程序
2010-08-26 15:48 1043问题的提出 作为 ... -
Oracle体系结构
2010-08-07 09:53 968Oracle体系结构 Oracle Server包括Oracl ... -
ocp sesson 3
2010-07-31 14:39 0show parameter undo 只有 默认情况下服务 ... -
ocp session 2
2010-07-25 17:00 0/home/oracle/raInventory/orains ... -
ocp session 1
2010-07-24 13:02 0ocp first lesson D:\oracle_cou ... -
Python的xmlrpc调试
2010-07-19 23:55 2070Python的xmlrpc 调 试 ----------- ... -
mdadm使用详解及RAID 5简单分析
2010-07-11 16:19 1351http://blog.csdn.net/chinalinux ... -
Linux的lvm的基本配置步骤
2010-07-11 14:53 12441.增加硬件 增加的ide硬盘前缀为hd,scs ... -
OCP study material
2010-07-11 13:52 0\\192.168.1.105watch -n 1 'stat ... -
apache+python+mod_python+django 编译安装指南
2010-06-24 17:25 14421、本文将知道你在 linux 下使用源码包安装 ... -
在ubuntu下配置apache运行python脚本
2010-06-22 16:11 2237常用的简单命令 sudo apt ... -
Python 2.5 Quick Reference
2010-06-21 11:18 1413... -
shell 面试题汇集
2010-06-10 19:50 1011利用 top 取某个进程的 CPU 的脚本 : ... -
shell程序面试题
2010-06-10 19:48 27751.要求分析Apache访问日志,找出里面数量在前面100位的 ... -
EMC技术支持工程师笔试部分试题回忆
2010-06-07 15:16 1599要查看更多EMC公司笔经相关信息,请访问EMC公司校园招聘CL ... -
linux shell 条件语句
2010-06-03 23:29 1737...
相关推荐
tomcat源码解析
Tomcat源码解析.pdf
tomcat的源码解析资料,加上tomcat的pdf解析中文版的,tomcat的源码。 挺不错的资源,大家可以学习下。
Tomcat源码剖析 : 整体架构 层层分析 源码解析 架构分析 (Http服务器功能:Socket通信(TCP/IP)、解析Http报文 Servlet容器功能:有很多Servlet(自带系统级Servlet+自定义Servlet),Servlet处理具体的业务逻辑...
Tomcat架构解析文档.zip
tomcat 源码分析系列文档 http深入分析,tomcat中类的加载,tomcat的启动,tomcat的容器思想,
tomcat 架构解析和优化。pdf tomcat 架构解析和优化。pdftomcat 架构解析和优化。pdf
本书并不是一本以源码分析为主的书,而且本书立意便是要与这类书区分开。因此如果你想仔细了解Tomcat的源代码,显然本书并不是你想要的。本书只是从架构设计上,对Tomcat的各组件进行了概念性讲解,如果你想阅读...
Tomcat源码解析。本地编译Tomcat源码。在项目根目录下手动创建pom.xml文件
总之,这份文档是一份十分有价值且详尽的Tomcat源码解析文档,不仅可以帮助读者更好地理解Tomcat的内部工作原理,还能够为读者提供一些实用的技巧和注意事项,帮助读者更好地使用和调试Tomcat。
以类图,剪短的文字讲解了tomcat的架构。真正做到会用tomcat和懂tomcat内部运行机制。
Tomcat源码Tomcat源码Tomcat源码Tomcat源码Tomcat源码Tomcat源码Tomcat源码
介绍了tomcat的架构,从源码分析tomcat组成!
这些资源文档是本人在网上搜索了好多关于tomcat源码讲解的文章之后,觉得对tomcat6源码讲解不错的文章的整理,文档有别人分析,本人只是整理;
Tomcat架构解析 基于Tomcat 8.5.x全面介绍了Tomcat的架构、各组件的实现方案以及使用方式,主要包括Tomcat的基础组件架构以及工作原理,Tomcat各组件的实现方案、使用方式以及详细配置说明,Tomcat与Web服务器集成...
基于Tomcat的全面解析应用服务器架构 涵盖Tomcat所有组件的详细配置
tomcat的基础脚本分析 tomcat的源码启动分析 tomcat的web应用启动分析 tomcat的socket分析 tomcat的cocket与容器对接时序分析
how tomcat work源码及中文翻译
tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载tomcat7源码下载