| 
 | WebObjects 5.2.3 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.webobjects.appserver.WOHTTPConnection
The WOHTTPConnection class is intended to be used as a client for HTTP
 communications. It gives direct access to HTTP contents and headers.
 WOHTTPConnection's sendRequest method allows you to send a
 WORequest object directly to the server specified by the constructor's
 host and port parameters, and readResponse
 allows you to receive WOResponse objects from that same server.
 
Use HTTP/1.1 protocol in WORequest whenever possible.
WORequest, 
WOResponse, 
WOHTTPConnection(java.lang.String, int), 
sendRequest(WORequest aRequest), 
readResponse()| Nested Class Summary | 
| Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding | 
| NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor | 
| Nested classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions | 
| NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility | 
| Field Summary | 
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding | 
| NullValue | 
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions | 
| KeyPathSeparator | 
| Constructor Summary | |
| WOHTTPConnection(String aHost,
                 int portNumber)Creates a WOHTTPConnection instance initialized with the specified host name and port number. | |
| WOHTTPConnection(String aHost,
                 int portNumber,
                 int timeout)Deprecated. Use setReceiveTimeout, setSendTimeout to control the timeout after creating an instance. | |
| Method Summary | |
| static boolean | canAccessFieldsDirectly()WOHTTPConnection's implementation of this static method returns true, indicating that key/value coding is allowed to access fields in this object if an appropriate method isn't present. | 
|  int | connectTimeout()Deprecated. There will be a connection only after a sendRequesthas been executed. Thus, it would make more sense to control the send timeout usingsetSendTimeout. | 
| static void | expectContentLengthHeader(boolean expectContentLengthHeader,
                          int contentTimeout)Deprecated. If you are using HTTP/1.1, there is no need to tell the receiver whether to expect content length since it follows RFC 2616 (HTTP/1.1). | 
|  boolean | followRedirects(boolean followRedirects)Gets boolean value indicating whether or not HTTP redirects (3xx) should be automatically followed. | 
|  Object | handleQueryWithUnboundKey(String key)Conformance to NSKeyValueCoding.ErrorHandling. | 
|  void | handleTakeValueForUnboundKey(Object value,
                             String key)Conformance to NSKeyValueCoding.ErrorHandling. | 
|  boolean | isConnected()Deprecated. This is meaningless since there will not be a connection before sendRequestis executed. | 
|  boolean | keepAliveEnabled()Gets the previously set boolean value to indicate if a connection should be left open after a request has been sent. | 
|  WOResponse | readResponse()Receives a response after sendRequestis executed. | 
|  long | readTimeout()Gets the read timeout interval set previously for a finer-grained read operation. | 
|  int | receiveTimeout()Gets the receive timeout interval. | 
|  boolean | sendRequest(WORequest request)Sends a WORequest requestto a destination connection point initialized in
 the constructorWOHTTPConnection. | 
|  int | sendTimeout()Gets the send timeout interval. | 
|  void | setConnectTimeout(int connectTimeout)Deprecated. There will be a connection only after a sendRequesthas been executed. Thus, it would make more sense to control the send timeout usingsetSendTimeout. | 
|  void | setFollowRedirects(boolean followRedirects)Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this class. | 
|  void | setKeepAliveEnabled(boolean keepAlive)Specifies according to keepAlivewhether the connection is to be left open
 after a request has been sent so that subsequent requests to the same destination
 connection point don't require the connection to be re-opened. | 
|  void | setReadTimeout(int readTimeout)Sets the timeout interval to control each finer-grained socket read operation when receiving data from a remote connection. | 
|  void | setReceiveTimeout(int receiveTimeout)Sets the receive timeout interval to receiveTimeoutmilliseconds. | 
|  void | setSendTimeout(int sendTimeout)Sets the send timeout interval to sendTimeoutmilliseconds. | 
| protected static Socket | socketForHostAndPortAndTimeout(String host,
                               int port,
                               int timeout)Protected class method that returns a java.net.Socketfor the
 provided hostname and port. | 
|  void | takeValueForKey(Object value,
                String key)Conformance to NSKeyValueCoding. | 
|  void | takeValueForKeyPath(Object value,
                    String keyPath)Conformance to NSKeyValueCodingAdditions. | 
|  String | toString() | 
|  void | unableToSetNullForKey(String key)Conformance to NSKeyValueCoding.ErrorHandling. | 
|  Object | valueForKey(String key)Conformance to NSKeyValueCoding. | 
|  Object | valueForKeyPath(String keyPath)Conformance to NSKeyValueCodingAdditions. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
public WOHTTPConnection(String aHost,
                        int portNumber)
aHost - the host name to connect toportNumber - the port number to connect to
public WOHTTPConnection(String aHost,
                        int portNumber,
                        int timeout)
aHost - the host name to connect toportNumber - the port number to connect totimeout - timeout interval in millisecondssetReceiveTimeout(int), 
setSendTimeout(int)| Method Detail | 
public static boolean canAccessFieldsDirectly()
public int connectTimeout()
sendRequest
             has been executed. Thus, it would make more sense to control the send timeout using
             setSendTimeout.
sendTimeout(), 
sendRequest(com.webobjects.appserver.WORequest)
public static void expectContentLengthHeader(boolean expectContentLengthHeader,
                                             int contentTimeout)
 Set the first parameter to false and supply an appropriate
 timeout if a content-length header might not be expected to be present.
 If you set the first parameter to true,
 the timeout parameter is ignored and, if no content-length header is found
 among the HTTP content, no data will be returned when reading from the
 socket. If a content-length header is detected, the value the header specifies will
 be used to determine how much data to accumulate independent of the
 contentTimeout.
expectContentLengthHeader - specifies whether a content-length
                                     header is expectedcontentTimeout - decides how long (in milliseconds)
                                     WOHTTPConnection should waitpublic boolean followRedirects(boolean followRedirects)
true if HTTP redirects should be automatically followed,
         false if notsetFollowRedirects(boolean)public Object handleQueryWithUnboundKey(String key)
handleQueryWithUnboundKey in interface NSKeyValueCoding.ErrorHandlingkey - NSKeyValueCoding.valueForKey(java.lang.String), 
NSKeyValueCoding.UnknownKeyException, 
NSKeyValueCoding.DefaultImplementation
public void handleTakeValueForUnboundKey(Object value,
                                         String key)
handleTakeValueForUnboundKey in interface NSKeyValueCoding.ErrorHandlingvalue - key - NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), 
NSKeyValueCoding.UnknownKeyException, 
NSKeyValueCoding.DefaultImplementationpublic boolean isConnected()
sendRequest is executed.
truesendRequest(com.webobjects.appserver.WORequest)public boolean keepAliveEnabled()
 The default value is true.
true if the connection will be left open after a request has
              been sent; false otherwisesetKeepAliveEnabled(boolean)public WOResponse readResponse()
sendRequest is executed. The response is then
 encapsulated as a WOResponse object and returned.
 
 Use setReceiveTimeout to control the receive timeout interval.
null if an error is detected while reading or
         interpreting the response.sendRequest(WORequest aRequest), 
setReceiveTimeout(int)public long readTimeout()
0 if not set previouslysetReadTimeout(int)public int receiveTimeout()
setReceiveTimeout(int timeout)public boolean sendRequest(WORequest request)
request to a destination connection point initialized in
 the constructor WOHTTPConnection. After a request has been sent, use
 readReponse to receive the response back.
 
 Use setSendTimeout to control the send timeout interval.
request - request sent to the server
true if the WORequest was successfully sent, or
                   false otherwiseWOHTTPConnection(java.lang.String, int, int), 
readResponse(), 
setSendTimeout(int), 
setKeepAliveEnabled(boolean flag)public int sendTimeout()
setSendTimeout(int timeout)public void setConnectTimeout(int connectTimeout)
sendRequest
             has been executed. Thus, it would make more sense to control the send timeout using
             setSendTimeout.
connectTimeout milliseconds.
 The default value for this timeout is 5 seconds unless overridden by the
 WOHTTPConnectTimeout property.
connectTimeout - the connection timeout intervalsetSendTimeout(int timeout), 
sendRequest(com.webobjects.appserver.WORequest)public void setFollowRedirects(boolean followRedirects)
 If there is a security manager, this method first calls the security manager's
 checkSetFactory method to ensure the operation is allowed. This could result
 in a SecurityException.
followRedirects - a boolean indicating whether or not to follow HTTP redirectsSecurityManager.checkSetFactory(), 
followRedirects(boolean)public void setKeepAliveEnabled(boolean keepAlive)
keepAlive whether the connection is to be left open
 after a request has been sent so that subsequent requests to the same destination
 connection point don't require the connection to be re-opened.
 The default for HTTP/1.1 is to keep the connection open while for HTTP/1.0 is to close the connection.
 In cases where you make a lot of one-time connections to different servers
 using HTTP/1.1, you want to consider using this method with keepAlive=false
 to prevent too many opened connections (sockets). Take note that this value overwrites the
 "connection" header in the WORequest and the default value is
 true.
 Thus, if your intention is to have "connection=close" in the header
 (which results in the connection closing),
 make sure that you set the parameter to false.
keepAlive - the flag that decides whether the connection is to be
                 left open after each request has been sentkeepAliveEnabled(), 
WORequestpublic void setReadTimeout(int readTimeout)
setReceiveTimeout.
 The default value is the system-dependent socket read timeout. Since there is a default receive timeout interval, you do not usually have to set the read timeout interval.
readTimeout - timeout in milliseconds to perform a finer-grained read operationreadTimeout(), 
setReceiveTimeout(int)public void setReceiveTimeout(int receiveTimeout)
receiveTimeout milliseconds.
 This timeout interval specifies the timeout applicable to the entire receive operation,
 including each individual sockets read operation. To control the timeout for each socket
 read operation, use setReadTimeout.
 
 The default value is 30 seconds unless overridden by the
 WOHTTPReceiveTimeout property
receiveTimeout - the new receive timeout interval in millisecondssetReadTimeout(int timeout), 
receiveTimeout()public void setSendTimeout(int sendTimeout)
sendTimeout milliseconds.
 The default value is 10 seconds.
sendTimeout - the new send timeout interval in millisecondssendTimeout()
protected static Socket socketForHostAndPortAndTimeout(String host,
                                                       int port,
                                                       int timeout)
java.net.Socket for the
 provided hostname and port. This method may throw a
 java.io.IOException or a
 java.net.UnknownHostException if it is unable to create a new
 socket based upon the supplied hostname and port.
host - the receiver's host nameport - the receiver's portNumbertimeout - timeout interval in milliseconds
java.net.Socket for the provided
                 hostname and port
public void takeValueForKey(Object value,
                            String key)
takeValueForKey in interface NSKeyValueCodingkey - identifies the property to be setvalue - the value to which the property specified by key
              should be setNSKeyValueCoding.NullValue, 
NSKeyValueCoding.valueForKey(java.lang.String), 
NSKeyValueCoding.DefaultImplementation, 
NSKeyValueCoding.ErrorHandling, 
NSKeyValueCoding.ErrorHandling.handleTakeValueForUnboundKey(java.lang.Object, java.lang.String)
public void takeValueForKeyPath(Object value,
                                String keyPath)
takeValueForKeyPath in interface NSKeyValueCodingAdditionskeyPath - identifies a derived property of the receivervalue - value to which the derived property identified by
                keyPath will be setNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), 
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String), 
NSKeyValueCodingAdditions.DefaultImplementationpublic String toString()
public void unableToSetNullForKey(String key)
unableToSetNullForKey in interface NSKeyValueCoding.ErrorHandlingkey - NSKeyValueCoding.takeValueForKey(Object value, String key), 
NSKeyValueCoding.DefaultImplementationpublic Object valueForKey(String key)
valueForKey in interface NSKeyValueCodingkey - identifies the property of an object
keyNSKeyValueCoding.NullValue, 
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), 
NSKeyValueCoding.DefaultImplementation, 
NSKeyValueCoding.ErrorHandling, 
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)public Object valueForKeyPath(String keyPath)
valueForKeyPath in interface NSKeyValueCodingAdditionskeyPath - identifies the derived property of an object
keyPathNSKeyValueCoding.valueForKey(java.lang.String), 
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String), 
NSKeyValueCodingAdditions.DefaultImplementation| 
 | Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||