Java Doc for HttpConnection.java in  » Web-Crawler » heritrix » org » apache » commons » 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 » Web Crawler » heritrix » org.apache.commons.httpclient 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.httpclient.HttpConnection

HttpConnection
public class HttpConnection (Code)
An abstraction of an HTTP InputStream and OutputStream pair, together with the relevant attributes.

The following options are set on the socket before getting the input/output streams in the HttpConnection.open() method:
Socket Method Sockets Option Configuration
java.net.Socket.setTcpNoDelay(boolean) SO_NODELAY HttpConnectionParams.setTcpNoDelay(boolean)
java.net.Socket.setSoTimeout(int) SO_TIMEOUT HttpConnectionParams.setSoTimeout(int)
java.net.Socket.setSendBufferSize(int) SO_SNDBUF HttpConnectionParams.setSendBufferSize(int)
java.net.Socket.setReceiveBufferSize(int) SO_RCVBUF HttpConnectionParams.setReceiveBufferSize(int)

author:
   Rod Waldhoff
author:
   Sean C. Sullivan
author:
   Ortwin Glueck
author:
   Jeff Dever
author:
   Mike Bowler
author:
   Oleg Kalnichevski
author:
   Michael Becke
author:
   Eric E Johnson
author:
   Laura Werner
version:
   $Revision: 5024 $ $Date: 2007-03-23 21:40:57 +0000 (Fri, 23 Mar 2007) $



Field Summary
protected  booleanisOpen
     Whether or not the connection is connected.

Constructor Summary
public  HttpConnection(String host, int port)
     Creates a new HTTP connection for the given host and port.
public  HttpConnection(String host, int port, Protocol protocol)
     Creates a new HTTP connection for the given host and port using the given protocol.
public  HttpConnection(String host, String virtualHost, int port, Protocol protocol)
     Creates a new HTTP connection for the given host with the virtual alias and port using given protocol.
public  HttpConnection(String proxyHost, int proxyPort, String host, int port)
     Creates a new HTTP connection for the given host and port via the given proxy host and port using the default protocol.
public  HttpConnection(HostConfiguration hostConfiguration)
     Creates a new HTTP connection for the given host configuration.
public  HttpConnection(String proxyHost, int proxyPort, String host, String virtualHost, int port, Protocol protocol)
     Creates a new HTTP connection for the given host with the virtual alias and port via the given proxy host and port using the given protocol.
Parameters:
  proxyHost - the host to proxy via
Parameters:
  proxyPort - the port to proxy via
Parameters:
  host - the host to connect to.
public  HttpConnection(String proxyHost, int proxyPort, String host, int port, Protocol protocol)
     Creates a new HTTP connection for the given host with the virtual alias and port via the given proxy host and port using the given protocol.
Parameters:
  proxyHost - the host to proxy via
Parameters:
  proxyPort - the port to proxy via
Parameters:
  host - the host to connect to.

Method Summary
protected  voidassertNotOpen()
     Throws an IllegalStateException if the connection is already open.
protected  voidassertOpen()
     Throws an IllegalStateException if the connection is not open.
public  voidclose()
     Closes the socket and streams.
public  booleancloseIfStale()
     Closes the connection if stale.
protected  voidcloseSocketAndStreams()
     Closes everything out.
public  voidflushRequestOutputStream()
     Flushes the output request stream.
public  StringgetHost()
     Returns the host.
public  HttpConnectionManagergetHttpConnectionManager()
     Returns the httpConnectionManager.
public  InputStreamgetLastResponseInputStream()
     Returns the stream used to read the last response's body.

Clients will generally not need to call this function unless using HttpConnection directly, instead of calling HttpClient.executeMethod . For those clients, call this function, and if it returns a non-null stream, close the stream before attempting to execute a method.

public  InetAddressgetLocalAddress()
     Return the local address used when creating the connection.
public  HttpConnectionParamsgetParams()
     Returns HttpConnectionParams HTTP protocol parameters associated with this method.
public  intgetPort()
     Returns the port of the host.
public  ProtocolgetProtocol()
     Returns the protocol used to establish the connection.
public  StringgetProxyHost()
     Returns the proxy host.
public  intgetProxyPort()
     Returns the port of the proxy host.
public  OutputStreamgetRequestOutputStream()
     Returns an OutputStream suitable for writing the request.
public  InputStreamgetResponseInputStream()
     Return a InputStream suitable for reading the response.
public  intgetSendBufferSize()
     Gets the socket's sendBufferSize.
public  intgetSoTimeout()
     Returns the Socket 's timeout, via Socket.getSoTimeout , if the connection is already open.
protected  SocketgetSocket()
     Returns the connection socket.
public  StringgetVirtualHost()
     Returns the target virtual host.
protected  booleanisLocked()
     Tests if the connection is locked.
public  booleanisOpen()
     Tests if the connection is open.
public  booleanisProxied()
     Returns true if the connection is established via a proxy, false otherwise.
public  booleanisResponseAvailable()
     Tests if input data avaialble.
public  booleanisResponseAvailable(int timeout)
     Tests if input data becomes available within the given period time in milliseconds.
public  booleanisSecure()
     Returns true if the connection is established over a secure protocol.
protected  booleanisStale()
     Determines whether this connection is "stale", which is to say that either it is no longer open, or an attempt to read the connection would fail.

Unfortunately, due to the limitations of the JREs prior to 1.4, it is not possible to test a connection to see if both the read and write channels are open - except by reading and writing.

public  booleanisStaleCheckingEnabled()
     Tests if stale checking is enabled.
public  booleanisTransparent()
     Indicates if the connection is completely transparent from end to end.
public  voidopen()
     Establishes a connection to the specified host and port (via a proxy if specified).
public  voidprint(String data)
    
public  voidprint(String data, String charset)
     Writes the specified String (as bytes) to the output stream.
public  voidprintLine(String data)
    
public  voidprintLine(String data, String charset)
     Writes the specified String (as bytes), followed by "\r\n".getBytes() to the output stream.
public  voidprintLine()
     Writes "\r\n".getBytes() to the output stream.
public  StringreadLine()
     Reads up to "\n" from the (unchunked) input stream.
public  StringreadLine(String charset)
     Reads up to "\n" from the (unchunked) input stream.
public  voidreleaseConnection()
     Releases the connection.
public  voidsetConnectionTimeout(int timeout)
     Sets the connection timeout.
public  voidsetHost(String host)
     Sets the host to connect to.
Parameters:
  host - the host to connect to.
public  voidsetHttpConnectionManager(HttpConnectionManager httpConnectionManager)
     Sets the httpConnectionManager.
public  voidsetLastResponseInputStream(InputStream inStream)
     Set the state to keep track of the last response for the last request.

The connection managers use this to ensure that previous requests are properly closed before a new request is attempted.

public  voidsetLocalAddress(InetAddress localAddress)
     Set the local address used when creating the connection.
protected  voidsetLocked(boolean locked)
     Locks or unlocks the connection.
public  voidsetParams(HttpConnectionParams params)
     Assigns HttpConnectionParams HTTP protocol parameters for this method.
public  voidsetPort(int port)
     Sets the port to connect to.
public  voidsetProtocol(Protocol protocol)
    
public  voidsetProxyHost(String host)
     Sets the host to proxy through.
public  voidsetProxyPort(int port)
     Sets the port of the host to proxy through.
public  voidsetSendBufferSize(int sendBufferSize)
     Sets the socket's sendBufferSize.
public  voidsetSoTimeout(int timeout)
     Set the Socket 's timeout, via Socket.setSoTimeout .
public  voidsetSocketTimeout(int timeout)
     Sets SO_TIMEOUT value directly on the underlying Socket socket .
public  voidsetStaleCheckingEnabled(boolean staleCheckEnabled)
     Sets whether or not isStale() will be called when testing if this connection is open.

Setting this flag to false will increase performance when reusing connections, but it will also make them less reliable.

public  voidsetVirtualHost(String host)
     Sets the virtual host to target.
Parameters:
  host - the virtual host name that should be used instead of physical host name when sending HTTP requests.
public  voidshutdownOutput()
     Attempts to shutdown the Socket 's output, via Socket.shutdownOutput() when running on JVM 1.3 or higher.
public  voidtunnelCreated()
     Instructs the proxy to establish a secure tunnel to the host.
public  voidwrite(byte[] data)
     Writes the specified bytes to the output stream.
public  voidwrite(byte[] data, int offset, int length)
     Writes length bytes in data starting at offset to the output stream.
public  voidwriteLine(byte[] data)
     Writes the specified bytes, followed by "\r\n".getBytes() to the output stream.
public  voidwriteLine()
     Writes "\r\n".getBytes() to the output stream.

Field Detail
isOpen
protected boolean isOpen(Code)
Whether or not the connection is connected.




Constructor Detail
HttpConnection
public HttpConnection(String host, int port)(Code)
Creates a new HTTP connection for the given host and port.
Parameters:
  host - the host to connect to
Parameters:
  port - the port to connect to



HttpConnection
public HttpConnection(String host, int port, Protocol protocol)(Code)
Creates a new HTTP connection for the given host and port using the given protocol.
Parameters:
  host - the host to connect to
Parameters:
  port - the port to connect to
Parameters:
  protocol - the protocol to use



HttpConnection
public HttpConnection(String host, String virtualHost, int port, Protocol protocol)(Code)
Creates a new HTTP connection for the given host with the virtual alias and port using given protocol.
Parameters:
  host - the host to connect to
Parameters:
  virtualHost - the virtual host requests will be sent to
Parameters:
  port - the port to connect to
Parameters:
  protocol - the protocol to use



HttpConnection
public HttpConnection(String proxyHost, int proxyPort, String host, int port)(Code)
Creates a new HTTP connection for the given host and port via the given proxy host and port using the default protocol.
Parameters:
  proxyHost - the host to proxy via
Parameters:
  proxyPort - the port to proxy via
Parameters:
  host - the host to connect to
Parameters:
  port - the port to connect to



HttpConnection
public HttpConnection(HostConfiguration hostConfiguration)(Code)
Creates a new HTTP connection for the given host configuration.
Parameters:
  hostConfiguration - the host/proxy/protocol to use



HttpConnection
public HttpConnection(String proxyHost, int proxyPort, String host, String virtualHost, int port, Protocol protocol)(Code)
Creates a new HTTP connection for the given host with the virtual alias and port via the given proxy host and port using the given protocol.
Parameters:
  proxyHost - the host to proxy via
Parameters:
  proxyPort - the port to proxy via
Parameters:
  host - the host to connect to. Parameter value must be non-null.
Parameters:
  virtualHost - No longer applicable.
Parameters:
  port - the port to connect to
Parameters:
  protocol - The protocol to use. Parameter value must be non-null.



HttpConnection
public HttpConnection(String proxyHost, int proxyPort, String host, int port, Protocol protocol)(Code)
Creates a new HTTP connection for the given host with the virtual alias and port via the given proxy host and port using the given protocol.
Parameters:
  proxyHost - the host to proxy via
Parameters:
  proxyPort - the port to proxy via
Parameters:
  host - the host to connect to. Parameter value must be non-null.
Parameters:
  port - the port to connect to
Parameters:
  protocol - The protocol to use. Parameter value must be non-null.




Method Detail
assertNotOpen
protected void assertNotOpen() throws IllegalStateException(Code)
Throws an IllegalStateException if the connection is already open.
throws:
  IllegalStateException - if connected



assertOpen
protected void assertOpen() throws IllegalStateException(Code)
Throws an IllegalStateException if the connection is not open.
throws:
  IllegalStateException - if not connected



close
public void close()(Code)
Closes the socket and streams.



closeIfStale
public boolean closeIfStale() throws IOException(Code)
Closes the connection if stale. true if the connection was stale and therefore closed, false otherwise.
See Also:   HttpConnection.isStale()
since:
   3.0



closeSocketAndStreams
protected void closeSocketAndStreams()(Code)
Closes everything out.



flushRequestOutputStream
public void flushRequestOutputStream() throws IOException(Code)
Flushes the output request stream. This method should be called to ensure that data written to the request OutputStream is sent to the server.
throws:
  IOException - if an I/O problem occurs



getHost
public String getHost()(Code)
Returns the host. the host.



getHttpConnectionManager
public HttpConnectionManager getHttpConnectionManager()(Code)
Returns the httpConnectionManager. HttpConnectionManager



getLastResponseInputStream
public InputStream getLastResponseInputStream()(Code)
Returns the stream used to read the last response's body.

Clients will generally not need to call this function unless using HttpConnection directly, instead of calling HttpClient.executeMethod . For those clients, call this function, and if it returns a non-null stream, close the stream before attempting to execute a method. Note that calling "close" on the stream returned by this function may close the connection if the previous response contained a "Connection: close" header.

An InputStream corresponding to the body of the lastresponse.



getLocalAddress
public InetAddress getLocalAddress()(Code)
Return the local address used when creating the connection. If null, the default address is used. InetAddress the local address to be used when creating Sockets



getParams
public HttpConnectionParams getParams()(Code)
Returns HttpConnectionParams HTTP protocol parameters associated with this method. HTTP parameters.
since:
   3.0



getPort
public int getPort()(Code)
Returns the port of the host. If the port is -1 (or less than 0) the default port for the current protocol is returned. the port.



getProtocol
public Protocol getProtocol()(Code)
Returns the protocol used to establish the connection. The protocol



getProxyHost
public String getProxyHost()(Code)
Returns the proxy host. the proxy host.



getProxyPort
public int getProxyPort()(Code)
Returns the port of the proxy host. the proxy port.



getRequestOutputStream
public OutputStream getRequestOutputStream() throws IOException, IllegalStateException(Code)
Returns an OutputStream suitable for writing the request.
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs a stream to write the request to



getResponseInputStream
public InputStream getResponseInputStream() throws IOException, IllegalStateException(Code)
Return a InputStream suitable for reading the response. InputStream The response input stream.
throws:
  IOException - If an IO problem occurs
throws:
  IllegalStateException - If the connection isn't open.



getSendBufferSize
public int getSendBufferSize() throws SocketException(Code)
Gets the socket's sendBufferSize. the size of the buffer for the socket OutputStream, -1 if the valuehas not been set and the socket has not been opened
throws:
  SocketException - if an error occurs while getting the socket value
See Also:   Socket.getSendBufferSize



getSoTimeout
public int getSoTimeout() throws SocketException(Code)
Returns the Socket 's timeout, via Socket.getSoTimeout , if the connection is already open. If no connection is open, return the value subsequent connection will use.

Note: This is not a connection timeout but a timeout on network traffic! the timeout valueHttpConnectionParams.getSoTimeoutHttpConnection.getParams




getSocket
protected Socket getSocket()(Code)
Returns the connection socket. the socket.
since:
   3.0



getVirtualHost
public String getVirtualHost()(Code)
Returns the target virtual host. the virtual host.



isLocked
protected boolean isLocked()(Code)
Tests if the connection is locked. Locked connections cannot be released. An attempt to release a locked connection will have no effect. true if the connection is locked, false otherwise.
since:
   3.0



isOpen
public boolean isOpen()(Code)
Tests if the connection is open. true if the connection is open



isProxied
public boolean isProxied()(Code)
Returns true if the connection is established via a proxy, false otherwise. true if a proxy is used to establish the connection, false otherwise.



isResponseAvailable
public boolean isResponseAvailable() throws IOException(Code)
Tests if input data avaialble. This method returns immediately and does not perform any read operations on the input socket boolean true if input data is available, false otherwise.
throws:
  IOException - If an IO problem occurs
throws:
  IllegalStateException - If the connection isn't open.



isResponseAvailable
public boolean isResponseAvailable(int timeout) throws IOException(Code)
Tests if input data becomes available within the given period time in milliseconds.
Parameters:
  timeout - The number milliseconds to wait for input data to become available boolean true if input data is availble, false otherwise.
throws:
  IOException - If an IO problem occurs
throws:
  IllegalStateException - If the connection isn't open.



isSecure
public boolean isSecure()(Code)
Returns true if the connection is established over a secure protocol. true if connected over a secure protocol.



isStale
protected boolean isStale() throws IOException(Code)
Determines whether this connection is "stale", which is to say that either it is no longer open, or an attempt to read the connection would fail.

Unfortunately, due to the limitations of the JREs prior to 1.4, it is not possible to test a connection to see if both the read and write channels are open - except by reading and writing. This leads to a difficulty when some connections leave the "write" channel open, but close the read channel and ignore the request. This function attempts to ameliorate that problem by doing a test read, assuming that the caller will be doing a write followed by a read, rather than the other way around.

To avoid side-effects, the underlying connection is wrapped by a BufferedInputStream , so although data might be read, what is visible to clients of the connection will not change with this call.throws:
  IOException - if the stale connection test is interrupted. true if the connection is already closed, or a read wouldfail.




isStaleCheckingEnabled
public boolean isStaleCheckingEnabled()(Code)
Tests if stale checking is enabled. true if enabled
See Also:   HttpConnection.isStale()HttpConnectionParams.isStaleCheckingEnabledHttpConnection.getParams



isTransparent
public boolean isTransparent()(Code)
Indicates if the connection is completely transparent from end to end. true if conncetion is not proxied or tunneled through a transparentproxy; false otherwise.



open
public void open() throws IOException(Code)
Establishes a connection to the specified host and port (via a proxy if specified). The underlying socket is created from the ProtocolSocketFactory .
throws:
  IOException - if an attempt to establish the connection results in anI/O error.



print
public void print(String data) throws IOException, IllegalStateException(Code)
HttpConnection.print(String,String)
Parameters:
  data - the string to be written
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs



print
public void print(String data, String charset) throws IOException, IllegalStateException(Code)
Writes the specified String (as bytes) to the output stream.
Parameters:
  data - the string to be written
Parameters:
  charset - the charset to use for writing the data
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs
since:
   3.0



printLine
public void printLine(String data) throws IOException, IllegalStateException(Code)
HttpConnection.printLine(String,String)
Parameters:
  data - the data to be written
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs



printLine
public void printLine(String data, String charset) throws IOException, IllegalStateException(Code)
Writes the specified String (as bytes), followed by "\r\n".getBytes() to the output stream.
Parameters:
  data - the data to be written
Parameters:
  charset - the charset to use for writing the data
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs
since:
   3.0



printLine
public void printLine() throws IOException, IllegalStateException(Code)
Writes "\r\n".getBytes() to the output stream.
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs



readLine
public String readLine() throws IOException, IllegalStateException(Code)
Reads up to "\n" from the (unchunked) input stream. If the stream ends before the line terminator is found, the last part of the string will still be returned.
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs a line from the response



readLine
public String readLine(String charset) throws IOException, IllegalStateException(Code)
Reads up to "\n" from the (unchunked) input stream. If the stream ends before the line terminator is found, the last part of the string will still be returned.
Parameters:
  charset - the charset to use for reading the data
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs a line from the response
since:
   3.0



releaseConnection
public void releaseConnection()(Code)
Releases the connection. If the connection is locked or does not have a connection manager associated with it, this method has no effect. Note that it is completely safe to call this method multiple times.



setConnectionTimeout
public void setConnectionTimeout(int timeout)(Code)
Sets the connection timeout. This is the maximum time that may be spent until a connection is established. The connection will fail after this amount of time.
Parameters:
  timeout - The timeout in milliseconds. 0 means timeout is not used.HttpConnectionParams.setConnectionTimeout(int)HttpConnection.getParams



setHost
public void setHost(String host) throws IllegalStateException(Code)
Sets the host to connect to.
Parameters:
  host - the host to connect to. Parameter value must be non-null.
throws:
  IllegalStateException - if the connection is already open



setHttpConnectionManager
public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager)(Code)
Sets the httpConnectionManager.
Parameters:
  httpConnectionManager - The httpConnectionManager to set



setLastResponseInputStream
public void setLastResponseInputStream(InputStream inStream)(Code)
Set the state to keep track of the last response for the last request.

The connection managers use this to ensure that previous requests are properly closed before a new request is attempted. That way, a GET request need not be read in its entirety before a new request is issued. Instead, this stream can be closed as appropriate.


Parameters:
  inStream - The stream associated with an HttpMethod.



setLocalAddress
public void setLocalAddress(InetAddress localAddress)(Code)
Set the local address used when creating the connection. If unset or null, the default address is used.
Parameters:
  localAddress - the local address to use



setLocked
protected void setLocked(boolean locked)(Code)
Locks or unlocks the connection. Locked connections cannot be released. An attempt to release a locked connection will have no effect.
Parameters:
  locked - true to lock the connection, false to unlockthe connection.
since:
   3.0



setParams
public void setParams(HttpConnectionParams params)(Code)
Assigns HttpConnectionParams HTTP protocol parameters for this method.
since:
   3.0
See Also:   HttpConnectionParams



setPort
public void setPort(int port) throws IllegalStateException(Code)
Sets the port to connect to.
Parameters:
  port - the port to connect to
throws:
  IllegalStateException - if the connection is already open



setProtocol
public void setProtocol(Protocol protocol)(Code)
Sets the protocol used to establish the connection
Parameters:
  protocol - The protocol to use.
throws:
  IllegalStateException - if the connection is already open



setProxyHost
public void setProxyHost(String host) throws IllegalStateException(Code)
Sets the host to proxy through.
Parameters:
  host - the host to proxy through.
throws:
  IllegalStateException - if the connection is already open



setProxyPort
public void setProxyPort(int port) throws IllegalStateException(Code)
Sets the port of the host to proxy through.
Parameters:
  port - the port of the host to proxy through.
throws:
  IllegalStateException - if the connection is already open



setSendBufferSize
public void setSendBufferSize(int sendBufferSize) throws SocketException(Code)
Sets the socket's sendBufferSize.
Parameters:
  sendBufferSize - the size to set for the socket OutputStream
throws:
  SocketException - if an error occurs while setting the socket value
See Also:   Socket.setSendBufferSize(int)HttpConnectionParams.setSendBufferSize(int)HttpConnection.getParams



setSoTimeout
public void setSoTimeout(int timeout) throws SocketException, IllegalStateException(Code)
Set the Socket 's timeout, via Socket.setSoTimeout . If the connection is already open, the SO_TIMEOUT is changed. If no connection is open, then subsequent connections will use the timeout value.

Note: This is not a connection timeout but a timeout on network traffic!
Parameters:
  timeout - the timeout value
throws:
  SocketException - - if there is an error in the underlyingprotocol, such as a TCP error.HttpConnectionParams.setSoTimeout(int)HttpConnection.getParams




setSocketTimeout
public void setSocketTimeout(int timeout) throws SocketException, IllegalStateException(Code)
Sets SO_TIMEOUT value directly on the underlying Socket socket . This method does not change the default read timeout value set via HttpConnectionParams .
Parameters:
  timeout - the timeout value
throws:
  SocketException - - if there is an error in the underlyingprotocol, such as a TCP error.
throws:
  IllegalStateException - if not connected
since:
   3.0



setStaleCheckingEnabled
public void setStaleCheckingEnabled(boolean staleCheckEnabled)(Code)
Sets whether or not isStale() will be called when testing if this connection is open.

Setting this flag to false will increase performance when reusing connections, but it will also make them less reliable. Stale checking ensures that connections are viable before they are used. When set to false some method executions will result in IOExceptions and they will have to be retried.


Parameters:
  staleCheckEnabled - true to enable isStale()
See Also:   HttpConnection.isStale()
See Also:   HttpConnection.isOpen()HttpConnectionParams.setStaleCheckingEnabled(boolean)HttpConnection.getParams



setVirtualHost
public void setVirtualHost(String host) throws IllegalStateException(Code)
Sets the virtual host to target.
Parameters:
  host - the virtual host name that should be used instead of physical host name when sending HTTP requests. Virtual host name can be set to null if virtual host name is notto be used
throws:
  IllegalStateException - if the connection is already open



shutdownOutput
public void shutdownOutput()(Code)
Attempts to shutdown the Socket 's output, via Socket.shutdownOutput() when running on JVM 1.3 or higher.



tunnelCreated
public void tunnelCreated() throws IllegalStateException, IOException(Code)
Instructs the proxy to establish a secure tunnel to the host. The socket will be switched to the secure socket. Subsequent communication is done via the secure socket. The method can only be called once on a proxied secure connection.
throws:
  IllegalStateException - if connection is not secure and proxied orif the socket is already secure.
throws:
  IOException - if an attempt to establish the secure tunnel results in anI/O error.



write
public void write(byte[] data) throws IOException, IllegalStateException(Code)
Writes the specified bytes to the output stream.
Parameters:
  data - the data to be written
throws:
  IllegalStateException - if not connected
throws:
  IOException - if an I/O problem occurs
See Also:   HttpConnection.write(byte[],int,int)



write
public void write(byte[] data, int offset, int length) throws IOException, IllegalStateException(Code)
Writes length bytes in data starting at offset to the output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.
Parameters:
  data - array containing the data to be written.
Parameters:
  offset - the start offset in the data.
Parameters:
  length - the number of bytes to write.
throws:
  IllegalStateException - if not connected
throws:
  IOException - if an I/O problem occurs



writeLine
public void writeLine(byte[] data) throws IOException, IllegalStateException(Code)
Writes the specified bytes, followed by "\r\n".getBytes() to the output stream.
Parameters:
  data - the bytes to be written
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs



writeLine
public void writeLine() throws IOException, IllegalStateException(Code)
Writes "\r\n".getBytes() to the output stream.
throws:
  IllegalStateException - if the connection is not open
throws:
  IOException - if an I/O problem occurs



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.