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

Response
final public class Response implements RoResponse,GlobalConstants(Code)
This class represents an intermediate response. It's used internally by the modules. When all modules have handled the response then the HTTPResponse fills in its fields with the data from this class.
version:
   0.3-2 18/06/1999
author:
   Ronald Tschalär


Field Summary
 intContentLength
     the message length of the response if either there is no data (in which case ContentLength=0) or if the message length is controlled by a Content-Length header.
 byte[]Data
     the data (body) returned.
 URIEffectiveURI
     the final URI of the document.
 CIHashtableHeaders
     any headers which were received and do not fit in the above list.
 StringReasonLine
     the reason line associated with the status code.
 intStatusCode
     the status code returned.
 CIHashtableTrailers
     any trailers which were received and do not fit in the above list.
 StringVersion
     the HTTP version of the response.
 intcd_type
    
 booleanfinal_resp
    
 booleangot_headers
    
 booleangot_trailers
    
 HTTPResponsehttp_resp
    
public  InputStreaminp_stream
     our input stream (usually from the stream demux).
 booleanisFirstResponse
    
 booleanreading_headers
    
 Requestreq
    
 Stringresource
    
 inttimeout
    
 booleantrailers_read
    

Constructor Summary
 Response(Request request, boolean used_proxy, StreamDemultiplexor stream_handler)
     Creates a new Response and registers it with the stream-demultiplexor.
 Response(Request request, InputStream is)
     Creates a new Response that reads from the given stream.
public  Response(String version, int status, String reason, NVPair[] headers, byte[] data, InputStream is, int cont_len)
     Create a new response with the given info.

Method Summary
public  voiddeleteHeader(String header)
     Removes a header field from the list of headers.
public  voiddeleteTrailer(String trailer)
     Removes a trailer field from the list of trailers.
 intgetContinue()
     Wait for either a '100 Continue' or an error.
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 field for a given header.
Parameters:
  hdr - the header name.
public  DategetHeaderAsDate(String hdr)
     retrieves the field for a given header.
public  intgetHeaderAsInt(String hdr)
     retrieves the field for a given header.
public synchronized  InputStreamgetInputStream()
     Gets an input stream from which the returned data can be read.
final public  StringgetReasonLine()
     give the reason line associated with the status code.
final public  intgetStatusCode()
     give the status code for this request.
public  StringgetTrailer(String trailer)
     Retrieves the field for a given trailer.
public  DategetTrailerAsDate(String trailer)
     Retrieves the field for a given trailer.
public  intgetTrailerAsInt(String trailer)
     Retrieves the field for a given tailer.
final public  StringgetVersion()
     get the HTTP version used for the response.
public synchronized  booleanhasEntity()
     Some responses such as those from a HEAD or with certain status codes don't have an entity.
 voidmarkAsFirstResponse(Request req)
     This marks this response as belonging to the first request made over an HTTPConnection.
 voidreadTrailers(InputStream inp)
     This is called by the StreamDemultiplexor to read all the trailers of a chunked encoded entity.
public  voidsetEffectiveURI(URI final_uri)
     set the final URI of the document.
public  voidsetEffectiveURL(URL final_url)
     set the final URL of the document.
public  voidsetHeader(String header, String value)
     Set a header field in the list of headers.
public  voidsetTrailer(String trailer, String value)
     Set a trailer field in the list of trailers.

Field Detail
ContentLength
int ContentLength(Code)
the message length of the response if either there is no data (in which case ContentLength=0) or if the message length is controlled by a Content-Length header. If neither of these, then it's -1



Data
byte[] Data(Code)
the data (body) returned.



EffectiveURI
URI EffectiveURI(Code)
the final URI of the document.



Headers
CIHashtable Headers(Code)
any headers which were received and do not fit in the above list.



ReasonLine
String ReasonLine(Code)
the reason line associated with the status code.



StatusCode
int StatusCode(Code)
the status code returned.



Trailers
CIHashtable Trailers(Code)
any trailers which were received and do not fit in the above list.



Version
String Version(Code)
the HTTP version of the response.



cd_type
int cd_type(Code)
this indicates how the length of the entity body is determined



final_resp
boolean final_resp(Code)
should this response be handled further?



got_headers
boolean got_headers(Code)
signals if we have got and parsed the headers yet



got_trailers
boolean got_trailers(Code)
signals if we have got and parsed the trailers yet



http_resp
HTTPResponse http_resp(Code)
the HTTPResponse we're coupled with



inp_stream
public InputStream inp_stream(Code)
our input stream (usually from the stream demux). Push input streams onto this if necessary.



isFirstResponse
boolean isFirstResponse(Code)



reading_headers
boolean reading_headers(Code)
signals if we in the process of reading the headers



req
Request req(Code)



resource
String resource(Code)
the resource in the request (for debugging purposes)



timeout
int timeout(Code)
the timeout for read operations



trailers_read
boolean trailers_read(Code)




Constructor Detail
Response
Response(Request request, boolean used_proxy, StreamDemultiplexor stream_handler) throws IOException(Code)
Creates a new Response and registers it with the stream-demultiplexor.



Response
Response(Request request, InputStream is) throws IOException(Code)
Creates a new Response that reads from the given stream. This is used for the CONNECT subrequest which is used in establishing an SSL tunnel through a proxy.
Parameters:
  request - the subrequest
Parameters:
  is - the input stream from which to read the headers anddata.



Response
public Response(String version, int status, String reason, NVPair[] headers, byte[] data, InputStream is, int cont_len)(Code)
Create a new response with the given info. This is used when creating a response in a requestHandler().

If data is not null then that is used; else if the is is not null that is used; else the entity is empty. If the input stream is used then cont_len specifies the length of the data that can be read from it, or -1 if unknown.
Parameters:
  version - the response version (such as "HTTP/1.1")
Parameters:
  status - the status code
Parameters:
  reason - the reason line
Parameters:
  headers - the response headers
Parameters:
  data - the response entity
Parameters:
  is - the response entity as an InputStream
Parameters:
  cont_len - the length of the data in the InputStream





Method Detail
deleteHeader
public void deleteHeader(String header)(Code)
Removes a header field from the list of headers. This is used by some modules when they process the header so that higher level stuff doesn't get confused when the headers and data don't match.
Parameters:
  header - The name of header field to remove.



deleteTrailer
public void deleteTrailer(String trailer)(Code)
Removes a trailer field from the list of trailers. This is used by some modules when they process the trailer so that higher level stuff doesn't get confused when the trailers and data don't match.
Parameters:
  trailer - The name of trailer field to remove.



getContinue
int getContinue() throws IOException(Code)
Wait for either a '100 Continue' or an error. the return status.



getData
public synchronized byte[] getData() throws IOException(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 called then this method only returns any unread data remaining on the stream and then closes it.
See Also:   Response.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



getEffectiveURI
final public URI getEffectiveURI() throws IOException(Code)
get the final URI of the document. This is set if the original request was deferred via the "moved" (301, 302, or 303) return status. the new URI, or null if not redirected
exception:
  IOException - If any exception occurs on the socket.



getEffectiveURL
final public URL getEffectiveURL() throws IOException(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.
exception:
  IOException - If any exception occurs on the socket.
See Also:   Response.getEffectiveURI



getHeader
public String getHeader(String hdr) throws IOException(Code)
retrieves the field 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.



getHeaderAsDate
public Date getHeaderAsDate(String hdr) throws IOException, IllegalArgumentException(Code)
retrieves the field 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 IllegalArgumentException 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:
  IOException - If any exception occurs on the socket.
exception:
  IllegalArgumentException - If the header cannot be parsedas a date or time.




getHeaderAsInt
public int getHeaderAsInt(String hdr) throws IOException, NumberFormatException(Code)
retrieves the field 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.



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



getReasonLine
final public String getReasonLine() throws IOException(Code)
give the reason line associated with the status code.
exception:
  IOException - If any exception occurs on the socket.



getStatusCode
final public int getStatusCode() throws IOException(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.



getTrailer
public String getTrailer(String trailer) throws IOException(Code)
Retrieves the field for a given trailer. Note that this should not be invoked until all the response data has been read. If invoked before, it will force the data to be read via getData().
Parameters:
  trailer - the trailer name. the value for the trailer, or null if non-existent.
exception:
  IOException - If any exception occurs on the socket.



getTrailerAsDate
public Date getTrailerAsDate(String trailer) throws IOException, IllegalArgumentException(Code)
Retrieves the field 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:
  IllegalArgumentException - If the header cannot be parsedas a date or time.




getTrailerAsInt
public int getTrailerAsInt(String trailer) throws IOException, NumberFormatException(Code)
Retrieves the field 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.



getVersion
final public String getVersion() throws IOException(Code)
get the HTTP version used for the response.
exception:
  IOException - If any exception occurs on the socket.



hasEntity
public synchronized boolean hasEntity() throws IOException(Code)
Some responses such as those from a HEAD or with certain status codes don't have an entity. This is detected by the client and can be queried here. Note that this won't try to do a read() on the input stream (it will however cause the headers to be read and parsed if not already done). true if the response has an entity, false otherwise
since:
   V0.3-1



markAsFirstResponse
void markAsFirstResponse(Request req)(Code)
This marks this response as belonging to the first request made over an HTTPConnection. The con and req parameters are needed in case we have to do a resend of the request - this is to handle buggy servers which barf upon receiving a request marked as HTTP/1.1 .
Parameters:
  con - The HTTPConnection used
Parameters:
  req - The Request sent



readTrailers
void readTrailers(InputStream inp) throws IOException(Code)
This is called by the StreamDemultiplexor to read all the trailers of a chunked encoded entity.
Parameters:
  inp - the raw input stream to read from
exception:
  IOException - if any IOException is thrown by the stream



setEffectiveURI
public void setEffectiveURI(URI final_uri)(Code)
set the final URI of the document. This is only for internal use.



setEffectiveURL
public void setEffectiveURL(URL final_url)(Code)
set the final URL of the document. This is only for internal use.
See Also:   Response.setEffectiveURI



setHeader
public void setHeader(String header, String value)(Code)
Set a header field in the list of headers. If the header already exists it will be overwritten; otherwise the header will be added to the list. This is used by some modules when they process the header so that higher level stuff doesn't get confused when the headers and data don't match.
Parameters:
  header - The name of header field to set.
Parameters:
  value - The value to set the field to.



setTrailer
public void setTrailer(String trailer, String value)(Code)
Set a trailer field in the list of trailers. If the trailer already exists it will be overwritten; otherwise the trailer will be added to the list. This is used by some modules when they process the trailer so that higher level stuff doesn't get confused when the trailer and data don't match.
Parameters:
  trailer - The name of trailer field to set.
Parameters:
  value - The value to set the field to.



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.