Java Doc for HTTPResponse.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) 


java.lang.Object
   HTTPClient.HTTPResponse

HTTPResponse
public class HTTPResponse implements GlobalConstants,HTTPClientModuleConstants(Code)
This defines the http-response class returned by the requests. It's basically a wrapper around the Response class which first lets all the modules handle the response before finally giving the info to the user.
version:
   0.3-2 18/06/1999
author:
   Ronald Tschalär
since:
   0.3



Constructor Summary
 HTTPResponse(HTTPClientModule[] modules, int timeout, Request orig)
     Creates a new HTTPResponse.

Method Summary
public synchronized  byte[]getData()
     Reads all the response data into a byte array.
final public  URIgetEffectiveURI()
     Get the final URI of the document.
final public  URLgetEffectiveURL()
     Get the final URL of the document.
public  StringgetHeader(String hdr)
     Retrieves the value for a given header.
Parameters:
  hdr - the header name.
public  DategetHeaderAsDate(String hdr)
     Retrieves the value for a given header.
public  intgetHeaderAsInt(String hdr)
     Retrieves the value for a given header.
public synchronized  InputStreamgetInputStream()
     Gets an input stream from which the returned data can be read.
 HTTPClientModule[]getModules()
    
final public  URIgetOriginalURI()
     Get the original URI used in the request.
final public  StringgetReasonLine()
     Give the reason line associated with the status code.
final public  StringgetServer()
     Get the name and type of server.
final public  intgetStatusCode()
     Give the status code for this request.
 intgetTimeout()
    
public  StringgetTrailer(String trailer)
     Retrieves the value for a given trailer.
public  DategetTrailerAsDate(String trailer)
     Retrieves the value for a given trailer.
public  intgetTrailerAsInt(String trailer)
     Retrieves the value for a given tailer.
final public  StringgetVersion()
     Get the HTTP version used for the response.
synchronized  booleanhandleResponse()
     Processes a Response.
 voidinit(Response resp)
     Copies the relevant fields from Response and marks this as initialized.
 voidinvokeTrailerHandlers(boolean force)
     This is invoked by the RespInputStream when it is close()'d.
public  EnumerationlistHeaders()
     Returns an enumeration of all the headers available via getHeader().
public  EnumerationlistTrailers()
     Returns an enumeration of all the trailers available via getTrailer().
 voidmarkAborted()
     Mark this request as having been aborted.
 voidset(Request req, Response resp)
    
 voidset(Request req, HttpOutputStream out_stream)
    
public  StringtoString()
     produces a full list of headers and their values, one per line.


Constructor Detail
HTTPResponse
HTTPResponse(HTTPClientModule[] modules, int timeout, Request orig)(Code)
Creates a new HTTPResponse.
Parameters:
  modules - the list of modules handling this response
Parameters:
  timeout - the timeout to be used on stream read()'s




Method Detail
getData
public synchronized byte[] getData() throws IOException, ModuleException(Code)
Reads all the response data into a byte array. Note that this method won't return until all the data has been received (so for instance don't invoke this method if the server is doing a server push). If getInputStream() had been previously invoked then this method only returns any unread data remaining on the stream and then closes it.

Note to the unwarry: code like System.out.println("The data: " + resp.getData()) will probably not do what you want - use System.out.println("The data: " + new String(resp.getData())) instead.
See Also:   HTTPResponse.getInputStream() an array containing the data (body) returned. If no datawas returned then it's set to a zero-length array.
exception:
  IOException - If any io exception occured while readingthe data
exception:
  ModuleException - if any module encounters an exception.




getEffectiveURI
final public URI getEffectiveURI() throws IOException, ModuleException(Code)
Get the final URI of the document. If the request was redirected via the "moved" (301, 302, 303, or 307) return status this returns the URI used in the last redirection; otherwise it returns the original URI. the effective URI
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getEffectiveURL
final public URL getEffectiveURL() throws IOException, ModuleException(Code)
Get the final URL of the document. This is set if the original request was deferred via the "moved" (301, 302, or 303) return status. the effective URL, or null if no redirection occured
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.
See Also:   HTTPResponse.getEffectiveURI



getHeader
public String getHeader(String hdr) throws IOException, ModuleException(Code)
Retrieves the value for a given header.
Parameters:
  hdr - the header name. the value for the header, or null if non-existent.
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getHeaderAsDate
public Date getHeaderAsDate(String hdr) throws IOException, IllegalArgumentException, ModuleException(Code)
Retrieves the value for a given header. The value is parsed as a date; if this fails it is parsed as a long representing the number of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an exception is thrown.
Note: When sending dates use Util.httpDate().
Parameters:
  hdr - the header name. the value for the header, or null if non-existent.
exception:
  IllegalArgumentException - if the header's value is neither alegal date nor a number.
exception:
  IOException - if any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getHeaderAsInt
public int getHeaderAsInt(String hdr) throws IOException, ModuleException, NumberFormatException(Code)
Retrieves the value for a given header. The value is parsed as an int.
Parameters:
  hdr - the header name. the value for the header if the header exists
exception:
  NumberFormatException - if the header's value is not a numberor if the header does not exist.
exception:
  IOException - if any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getInputStream
public synchronized InputStream getInputStream() throws IOException, ModuleException(Code)
Gets an input stream from which the returned data can be read. Note that if getData() had been previously invoked it will actually return a ByteArrayInputStream created from that data.
See Also:   HTTPResponse.getData() the InputStream.
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getModules
HTTPClientModule[] getModules()(Code)



getOriginalURI
final public URI getOriginalURI()(Code)
Get the original URI used in the request. the URI used in primary request



getReasonLine
final public String getReasonLine() throws IOException, ModuleException(Code)
Give the reason line associated with the status code.
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getServer
final public String getServer() throws IOException, ModuleException(Code)
Get the name and type of server.
See Also:   HTTPResponse.getHeader(java.lang.String)
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getStatusCode
final public int getStatusCode() throws IOException, ModuleException(Code)
Give the status code for this request. These are grouped as follows:
  • 1xx - Informational (new in HTTP/1.1)
  • 2xx - Success
  • 3xx - Redirection
  • 4xx - Client Error
  • 5xx - Server Error

exception:
  IOException - if any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getTimeout
int getTimeout()(Code)



getTrailer
public String getTrailer(String trailer) throws IOException, ModuleException(Code)
Retrieves the value for a given trailer. This should not be invoked until all response data has been read. If invoked before it will call getData() to force the data to be read.
Parameters:
  trailer - the trailer name. the value for the trailer, or null if non-existent.
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.
See Also:   HTTPResponse.getData()



getTrailerAsDate
public Date getTrailerAsDate(String trailer) throws IOException, IllegalArgumentException, ModuleException(Code)
Retrieves the value for a given trailer. The value is parsed as a date; if this fails it is parsed as a long representing the number of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an IllegalArgumentException is thrown.
Note: When sending dates use Util.httpDate().
Parameters:
  trailer - the trailer name. the value for the trailer, or null if non-existent.
exception:
  IllegalArgumentException - if the trailer's value is neither alegal date nor a number.
exception:
  IOException - if any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getTrailerAsInt
public int getTrailerAsInt(String trailer) throws IOException, ModuleException, NumberFormatException(Code)
Retrieves the value for a given tailer. The value is parsed as an int.
Parameters:
  trailer - the tailer name. the value for the trailer if the trailer exists
exception:
  NumberFormatException - if the trailer's value is not a numberor if the trailer does not exist.
exception:
  IOException - if any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



getVersion
final public String getVersion() throws IOException, ModuleException(Code)
Get the HTTP version used for the response.
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



handleResponse
synchronized boolean handleResponse() throws IOException, ModuleException(Code)
Processes a Response. This is done by calling the response handler in each module. When all is done, the various fields of this instance are intialized from the last Response.
exception:
  IOException - if any handler throws an IOException.
exception:
  ModuleException - if any module encounters an exception. true if a new request was generated. This is used for internalsubrequests only



init
void init(Response resp)(Code)
Copies the relevant fields from Response and marks this as initialized.
Parameters:
  resp - the Response class to copy from



invokeTrailerHandlers
void invokeTrailerHandlers(boolean force) throws IOException, ModuleException(Code)
This is invoked by the RespInputStream when it is close()'d. It just invokes the trailer handler in each module.
Parameters:
  force - invoke the handlers even if not initialized yet?
exception:
  IOException - if thrown by any module
exception:
  ModuleException - if thrown by any module



listHeaders
public Enumeration listHeaders() throws IOException, ModuleException(Code)
Returns an enumeration of all the headers available via getHeader().
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



listTrailers
public Enumeration listTrailers() throws IOException, ModuleException(Code)
Returns an enumeration of all the trailers available via getTrailer().
exception:
  IOException - If any exception occurs on the socket.
exception:
  ModuleException - if any module encounters an exception.



markAborted
void markAborted()(Code)
Mark this request as having been aborted. It's invoked by HTTPConnection.stop().



set
void set(Request req, Response resp)(Code)

Parameters:
  req - the request
Parameters:
  resp - the response



set
void set(Request req, HttpOutputStream out_stream)(Code)

Parameters:
  req - the request
Parameters:
  resp - the response



toString
public String toString()(Code)
produces a full list of headers and their values, one per line. a string containing the headers



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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