Java Doc for HTTPClientModule.java in  » Net » SkunkDAV » HTTPClient » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » SkunkDAV » HTTPClient 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


HTTPClient.HTTPClientModule

All known Subclasses:   HTTPClient.CookieModule,  HTTPClient.ContentEncodingModule,  HTTPClient.ContentMD5Module,  HTTPClient.TransferEncodingModule,  HTTPClient.DefaultModule,  HTTPClient.RedirectionModule,  HTTPClient.RetryModule,  HTTPClient.AuthorizationModule,
HTTPClientModule
public interface HTTPClientModule extends HTTPClientModuleConstants(Code)
This is the interface that a module must implement. There are two parts during a request: the construction of the request, and the handling of the response. A request may cycle through these parts multiple times when a module generates additional subrequests (such as a redirection status handling module might do).

In the first step the request handler is invoked; here the headers, the request-uri, etc. can be modified, or a complete response can be generated. Then, if no response was generated, the request is sent over the wire. In the second step the response handlers are invoked. These may modify the response or, in phase 2, may generate a new request; the returned status from the phase 2 handler specifies how the processing of the request or response should further proceed.

The response handling is split into three phases. In the first phase the response handling cannot be modified; this is so that all modules get a chance to see the returned response. Modules will typically make notes of responses and do certain header processing here (for example the cookie module does it's work in this phase). In the second phase modules may generate new subrequests or otherwise control the further handling of the response. This is typically used for response status handling (such as for redirections and authentication). Finally, if no new subrequest was generated, the phase 3 response handlers are invoked so that modules can perform any necessary cleanups and final processing (no additional subrequests can be made anymore). It is recommended that any response processing which needn't be done if the request is not returned to the user is deferred until this phase. For example, the Content-MD5, Content-Encoding and Transfer-Encoding modules do their work in this phase as the body is usually discarded if a new subrequest is generated.

When the user invokes any request method (such as Get(...)) a list of of modules to be used is built. Then, for each module in the list, an instance is created using the Class.newInstance() method. This means that each module must have a constructor which takes no arguments. This instance is then used to handle the request, its response, and any additional subrequests and their responses. In this way a module can easily keep state between related subrequests. For example, a redirection module might want to keep track of the number of redirections made to detect redirect loops; it could do this by defining an instance variable and incrementing it each time the request handler is invoked.
version:
   0.3-2 18/06/1999
author:
   Ronald Tschalär
since:
   V0.3





Method Summary
public  intrequestHandler(Request request, Response[] response)
     This is invoked before the request is sent.
public  voidresponsePhase1Handler(Response response, RoRequest request)
     The phase 1 response handler.
public  intresponsePhase2Handler(Response response, Request request)
     The phase 2 response handler.
public  voidresponsePhase3Handler(Response response, RoRequest request)
     The phase 3 response handler.
public  voidtrailerHandler(Response response, RoRequest request)
     The chunked transfer-encoding (and in future maybe others) can contain trailer fields at the end of the body.



Method Detail
requestHandler
public int requestHandler(Request request, Response[] response) throws IOException, ModuleException(Code)
This is invoked before the request is sent. A module will typically use this to make a note of headers, to modify headers and/or data, or even generate and return a response (e.g. for a cache module). If a response is generated the module must return the appropriate return code (REQ_RESPONSE or REQ_RETURN).

Return codes for phase 1 (defined in HTTPClientModuleConstants.java)

REQ_CONTINUE continue processing
REQ_RESTART restart processing with first module
REQ_SHORTCIRC stop processing and send
REQ_RESPONSE go to phase 2
REQ_RETURN return response immediately (no processing)
REQ_NEWCON_RST use a new HTTPConnection, restart processing
REQ_NEWCON_SND use a new HTTPConnection, send immediately

Parameters:
  request - the request - may be modified as needed
Parameters:
  response - the response if the status is REQ_RESPONSE or REQ_RETURN status code REQ_XXX specifying further action
exception:
  IOException - if an IOException occurs on the socket
exception:
  ModuleException - if an exception occurs during the handlingof the request



responsePhase1Handler
public void responsePhase1Handler(Response response, RoRequest request) throws IOException, ModuleException(Code)
The phase 1 response handler. This will be invoked for every response. Modules will typically make notes of the response and do any header processing which must always be performed.
Parameters:
  response - the response - may be modified
Parameters:
  request - the original request
exception:
  IOException - if an IOException occurs on the socket
exception:
  ModuleException - if an exception occurs during the handlingof the response



responsePhase2Handler
public int responsePhase2Handler(Response response, Request request) throws IOException, ModuleException(Code)
The phase 2 response handler. A module may modify the response or generate a new request (e.g. for redirection). This handler will only be invoked for a given module if all previous modules returned RSP_CONTINUE. If the request is modified the handler must return an appropriate return code (RSP_REQUEST, RSP_SEND, RSP_NEWCON_REQ or RSP_NEWCON_SND). If any other code is return the request must not be modified.

Return codes for phase 2 (defined in HTTPClientModuleConstants.java)

RSP_CONTINUE continue processing
RSP_RESTART restart processing with first module (phase 1)
RSP_SHORTCIRC stop processing and return
RSP_REQUEST go to phase 1
RSP_SEND send request immediately (no processing)
RSP_NEWCON_REQ go to phase 1 using a new HTTPConnection
RSP_NEWCON_SND send request using a new HTTPConnection

Parameters:
  response - the response - may be modified
Parameters:
  request - the request; if the status is RSP_REQUEST then thismust contain the new request; however do not modifythis if you don't return a RSP_REQUEST status. status code RSP_XXX specifying further action
exception:
  IOException - if an IOException occurs on the socket
exception:
  ModuleException - if an exception occurs during the handlingof the response



responsePhase3Handler
public void responsePhase3Handler(Response response, RoRequest request) throws IOException, ModuleException(Code)
The phase 3 response handler. This will only be invoked if no new subrequest was generated in phase 2. Modules should defer any repsonse handling which need only be done if the response is returned to the user to this phase.
Parameters:
  response - the response - may be modified
Parameters:
  request - the original request
exception:
  IOException - if an IOException occurs on the socket
exception:
  ModuleException - if an exception occurs during the handlingof the response



trailerHandler
public void trailerHandler(Response response, RoRequest request) throws IOException, ModuleException(Code)
The chunked transfer-encoding (and in future maybe others) can contain trailer fields at the end of the body. Since the responsePhaseXHandler()'s are invoked before the body is read and therefore do not have access to the trailers (unless they force the complete body to be read) this method will be invoked when the trailers have been read and parsed (sort of a post-response handling).

Note: This method must not modify any part of the response other than the trailers.
Parameters:
  response - the response
Parameters:
  request - the request
exception:
  IOException - if an IOException occurs on the socket
exception:
  ModuleException - if an exception occurs during the handlingof the trailers




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.