com.sapportals.portal.ivs.http

Interface IHttpClient


public interface IHttpClient

Title: iViewSever for SAP v6.0 - System Landscape Description: Copyright: Copyright (c) 2002 Company: SAP Ra'anana Israel


Method Summary
 void addPostData(String postData)
          TODO documentation
 void disconnect()
          Dissconnect the connection
 String getCookie()
          TODO documentation
 URL getCurrentURL()
          Return the url the HttpClient object last retreived.
 String getHeaderFieldKey(int pos)
          after the send() method was called , use this method to get the HTTP header name by specifying the header position.
 String getResponseBody()
          after the send() method was called , use this method to get the HTTP response body text that was returned by the HTTP remote server.
 String getResponseHeader(int pos)
          after the send() method was called , use this method to get the HTTP header value by specifying the header position.
 String getResponseHeader(String headerName)
          after the send() method was called , use this method to get the HTTP header value by specifying the header name returned by the remote HTTP server.
 List getResponseHeaders()
          Return all the headers value in a list of String objects
 InputStream getResponseInputStream()
          return the entire server response in an InputStream.
 int getStatusCode()
          after the send() method was called , use this method to get the HTTP status code returned by the remote HTTP server.
 String getStatusMessage()
          after the send() method was called , use this method to get the HTTP status message returned by the remote HTTP server.
 void openConnection(String method, String url)
          Opens a HTTP connection to a remote server
 void openConnection(String method, String url, String username, String password)
          Opens a HTTP connection to a remote server using basic authintication
 void putBaseHerf(boolean set)
          Put the base href according the URL
 int send()
          send the request to the remote server.
 void setCookie(String cookie)
          TODO documentation
 void setFollowRedirects(boolean set)
          TODO documentation
 void setPassword(String password)
          Set the password to use in the next request for basic authintication.
 void setProxyServer(String proxyServer, int port)
          Set the proxy server and port to use if there is one.
 void setRequestProperty(String headerName, String headerValue)
          Set the request header of a request, if the header already exists the value given overrides the old value.
 void setUsername(String user)
          Set the username to use in the next request for basic authintication.
 

Method Detail

openConnection

void openConnection(String method,
                    String url)
                    throws NullPointerException,
                           IOException
Opens a HTTP connection to a remote server

Parameters:
method - the method to use in the url request. (GET,POST,PUT etc)
url - the url to use in the HTTP request
Throws:
NullPointerException - if an null argument was sent
IOException - if the OpenConnection method failed.

disconnect

void disconnect()
Dissconnect the connection


openConnection

void openConnection(String method,
                    String url,
                    String username,
                    String password)
                    throws NullPointerException,
                           IOException
Opens a HTTP connection to a remote server using basic authintication

Parameters:
method - the method to use in the url request. (GET,POST,PUT etc)
url - the url to use in the HTTP request
username - username to use in the request
password - password to use in the request
Throws:
NullPointerException - if an null argument was sent
IOException - if the OpenConnection method failed.

setRequestProperty

void setRequestProperty(String headerName,
                        String headerValue)
                        throws HttpClientException
Set the request header of a request, if the header already exists the value given overrides the old value.

Parameters:
headerName - header name to add to the HTTP request headers
headerValue - header value to use with the header.
Throws:
HttpClientException

send

int send()
         throws IOException,
                HttpClientException
send the request to the remote server. this method should be used only after openConnection(java.lang.String, java.lang.String) method was called. Returns the status code of the http connection response.

Throws:
IOException
HttpClientException

getStatusCode

int getStatusCode()
                  throws IOException,
                         HttpClientException
after the send() method was called , use this method to get the HTTP status code returned by the remote HTTP server.

Returns:
integer value of the status code
Throws:
IOException
HttpClientException

getStatusMessage

String getStatusMessage()
                        throws IOException,
                               HttpClientException
after the send() method was called , use this method to get the HTTP status message returned by the remote HTTP server.

Returns:
String representation of the status code message
Throws:
IOException
HttpClientException

getResponseHeader

String getResponseHeader(String headerName)
                         throws IOException,
                                HttpClientException
after the send() method was called , use this method to get the HTTP header value by specifying the header name returned by the remote HTTP server.

Parameters:
headerName - header name that we wish to get the value from
Returns:
the value of the specified header.
Throws:
IOException
HttpClientException

getResponseHeader

String getResponseHeader(int pos)
                         throws IOException,
                                HttpClientException
after the send() method was called , use this method to get the HTTP header value by specifying the header position.

Parameters:
pos - header position in the list of headers that were returned by the remote server
Returns:
the value of the specified header by it's position.
Throws:
IOException
HttpClientException

getHeaderFieldKey

String getHeaderFieldKey(int pos)
                         throws IOException,
                                HttpClientException
after the send() method was called , use this method to get the HTTP header name by specifying the header position.

Parameters:
pos - header position in the list of headers that were returned by the remote server
Returns:
the Name of the header according to it's postion.
Throws:
IOException
HttpClientException

getResponseBody

String getResponseBody()
                       throws IOException
after the send() method was called , use this method to get the HTTP response body text that was returned by the HTTP remote server.

Returns:
the body text of the response.
Throws:
IOException

getResponseInputStream

InputStream getResponseInputStream()
                                   throws IOException,
                                          HttpClientException
return the entire server response in an InputStream.

Returns:
InputStream of the Entire response.
Throws:
IOException
HttpClientException

setUsername

void setUsername(String user)
Set the username to use in the next request for basic authintication.

Parameters:
user - username to set.

setPassword

void setPassword(String password)
Set the password to use in the next request for basic authintication.

Parameters:
password - username to set.

setProxyServer

void setProxyServer(String proxyServer,
                    int port)
                    throws NullPointerException,
                           IndexOutOfBoundsException
Set the proxy server and port to use if there is one.

Parameters:
proxyServer - - the name or IP address of the proxy server to use
port - - the port to connect to the proxy server.
Throws:
NullPointerException - thrown if a null reference is sent
IndexOutOfBoundsException

getResponseHeaders

List getResponseHeaders()
                        throws HttpClientException
Return all the headers value in a list of String objects

Returns:
List of String objects
Throws:
HttpClientException

getCurrentURL

URL getCurrentURL()
                  throws HttpClientException
Return the url the HttpClient object last retreived.

Throws:
HttpClientException

getCookie

String getCookie()
TODO documentation

Returns:
String

setCookie

void setCookie(String cookie)
TODO documentation

Parameters:
cookie -

setFollowRedirects

void setFollowRedirects(boolean set)
TODO documentation

Parameters:
set -

addPostData

void addPostData(String postData)
TODO documentation

Parameters:
postData -

putBaseHerf

void putBaseHerf(boolean set)
Put the base href according the URL

Parameters:
set -
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] EP-RUNTIME [sap.com] tc/ep/connectivity/services/api api EP-PIN


Copyright 2011 SAP AG Complete Copyright Notice