wttools.protocols.simple.http
Class ProtocolImpl

java.lang.Object
  |
  +--wttools.protocols.AbstractProtocol
        |
        +--wttools.protocols.simple.http.ProtocolImpl
All Implemented Interfaces:
ProtocolIfc

public class ProtocolImpl
extends AbstractProtocol

Class HTTPImpl implements

Version:
$Revision: 1.4 $
Author:
Artur Hefczyc

Field Summary
protected  boolean connected
          Describe variable connected here.
protected  int connectionCode
          Describe variable connectionCode here.
protected  java.util.HashMap headers
          Describe variable headers here.
protected  HTTPInputStream inputStream
          Describe variable inputStream here.
protected  HTTPOutputStream outputStream
          Describe variable outputStream here.
protected  java.net.Socket socket
          Describe variable socket here.
protected  float transferSpeed
          Describe variable transferSpeed here.
 
Fields inherited from class wttools.protocols.AbstractProtocol
allowAllCookies, allowRedirect, allowUserInteraction, bytesDownloaded, clientId, debug, inputBufferSize, keepAlive, requestData, streamReadTimeout, uri, userName, userPassword
 
Fields inherited from interface wttools.protocols.ifc.ProtocolIfc
CODE_BAD_REQUEST, CODE_CONNECTION_ERROR, CODE_CONNECTION_OK, CODE_FORBIDDEN, CODE_HOST_NOT_FOUND, CODE_INTERNAL_SERVER_ERROR, CODE_LENGTH_REQUIRED, CODE_NETWORK_NOT_REACHABLE, CODE_NO_CONTENT, CODE_NOT_FOUND, CODE_NOT_INITIALIZED, CODE_PARTIAL_CONTENT, CODE_REDIRECT, CODE_REQUEST_TIMEOUT, CODE_SERVER_NOT_REACHABLE, CODE_UNAUTHORIZED, CODE_VERSION_NOT_SUPPORTED, METHOD_GET, METHOD_HEAD
 
Constructor Summary
ProtocolImpl()
           
 
Method Summary
protected  void closeSocket()
          closeSocket method performs
 void connect()
          connect method performs
 void disconnect()
          disconnect method performs
 java.util.HashMap getAllHeaders()
          getAllHeaders method performs
 java.lang.Object getConnectionInfo()
          getConnectionInfo method performs
 int getConnectionResult()
          getConnectionResult method performs
 java.util.List getConnectionStatuses()
          getConnectionStatuses method performs
 long getContentLength()
          getContentLength method returns expected content length.
 java.lang.String getContentType()
          getContentType method returns type of data stored in resource.
 URI getEffectiveURI()
          getEffectiveURI returns effective uri of requested resource.
 java.lang.String getHeaderStrValue(java.lang.String header_key)
          getHeaderStrValue method performs
 java.io.InputStream getInputStream()
          Get the value of inputStream.
 java.lang.String getProtocolType()
          getProtocolType method performs
 java.lang.String getServerId()
          getServerId method returns web server identification string detected during making connection.
 float getTransferSpeed()
          getTransferSpeed method performs
protected  void initialize(int method)
          initialize method performs
protected  void openSocket()
          openSocket method performs
protected  int parseResponseCode(java.lang.String msg_str)
          parseResponseCode method performs
 void setURI(URI v)
          setURI method performs
protected  int translateResponseCode(int code)
           
 
Methods inherited from class wttools.protocols.AbstractProtocol
deb, getClientId, getContentData, getHeaderIntValue, getInputBufferSize, getRealContentSize, getRequestData, getStreamReadTimeout, getURI, getUserName, getUserPassword, isAllowAllCookies, isAllowRedirect, isAllowUserInteraction, isDebug, isErrorRecoverable, isKeepAlive, saveContent, saveContent, setAllowAllCookies, setAllowRedirect, setAllowUserInteraction, setClientId, setDebug, setInputBufferSize, setKeepAlive, setRequestData, setStreamReadTimeout, setUserName, setUserPassword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStream

protected HTTPInputStream inputStream
Describe variable inputStream here.

outputStream

protected HTTPOutputStream outputStream
Describe variable outputStream here.

socket

protected java.net.Socket socket
Describe variable socket here.

headers

protected java.util.HashMap headers
Describe variable headers here.

connected

protected boolean connected
Describe variable connected here.

connectionCode

protected int connectionCode
Describe variable connectionCode here.

transferSpeed

protected float transferSpeed
Describe variable transferSpeed here.
Constructor Detail

ProtocolImpl

public ProtocolImpl()
Method Detail

setURI

public void setURI(URI v)
            throws java.io.IOException
setURI method performs
Overrides:
setURI in class AbstractProtocol
Parameters:
v - an URI value
Throws:
java.io.IOException - if an error occurs

getProtocolType

public java.lang.String getProtocolType()
getProtocolType method performs
Returns:
a String value

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get the value of inputStream.
Returns:
value of inputStream.

getConnectionResult

public int getConnectionResult()
                        throws java.io.IOException
getConnectionResult method performs
Returns:
an int value
Throws:
java.io.IOException - if an error occurs

connect

public void connect()
             throws java.io.IOException
connect method performs
Throws:
java.io.IOException - if an error occurs

disconnect

public void disconnect()
                throws java.io.IOException
disconnect method performs
Throws:
java.io.IOException - if an error occurs

getConnectionInfo

public java.lang.Object getConnectionInfo()
getConnectionInfo method performs
Returns:

getConnectionStatuses

public java.util.List getConnectionStatuses()
getConnectionStatuses method performs
Returns:

getHeaderStrValue

public java.lang.String getHeaderStrValue(java.lang.String header_key)
                                   throws java.io.IOException
getHeaderStrValue method performs
Parameters:
header_key - a String value
Returns:
a String value

getAllHeaders

public java.util.HashMap getAllHeaders()
                                throws java.io.IOException
getAllHeaders method performs
Returns:
a HashMap value

openSocket

protected void openSocket()
                   throws java.io.IOException
openSocket method performs
Throws:
java.io.IOException - if an error occurs

getTransferSpeed

public float getTransferSpeed()
getTransferSpeed method performs
Returns:
a float value

closeSocket

protected void closeSocket()
                    throws java.io.IOException
closeSocket method performs
Throws:
java.io.IOException - if an error occurs

initialize

protected void initialize(int method)
                   throws java.io.IOException
initialize method performs
Parameters:
method - an int value

parseResponseCode

protected int parseResponseCode(java.lang.String msg_str)
parseResponseCode method performs
Parameters:
msg_str - a String value
Returns:
an int value

getContentLength

public long getContentLength()
                      throws java.io.IOException
Description copied from interface: ProtocolIfc
getContentLength method returns expected content length. In many situations web server sends size of resource data, but sometimes we don't know how much data we receive till end of transmision. If expected content length is not known protocol should return -1.
Returns:

getContentType

public java.lang.String getContentType()
                                throws java.io.IOException
Description copied from interface: ProtocolIfc
getContentType method returns type of data stored in resource. for some protocols implementation it is easy to return info received from web server (HTTP server returns Content-Type header with such info) for others it is necessary to create engine to determine content type. This engine may base on file extension or based on mime-magic file.
Returns:

getServerId

public java.lang.String getServerId()
                             throws java.io.IOException
Description copied from interface: ProtocolIfc
getServerId method returns web server identification string detected during making connection. in HTTP protocol server identification string can be found in header named Server.
Returns:

translateResponseCode

protected int translateResponseCode(int code)

getEffectiveURI

public URI getEffectiveURI()
                    throws java.io.IOException
Description copied from interface: ProtocolIfc
getEffectiveURI returns effective uri of requested resource. If during connecting to web server redirection response occurs it means that effective URI is different then original.
Following copied from interface: wttools.protocols.ifc.ProtocolIfc
Returns:
an URI value of effective resource URI.


Copyright © GNU, wttools developers Team.