net.rim.device.api.io.http
Interface HttpServerConnection

All Superinterfaces:
Connection, ContentConnection, InputConnection, OutputConnection, StreamConnection

public interface HttpServerConnection
extends ContentConnection

This class is a mirror image of HttpConnection but defines some additional functionality for server side.

Since:
BlackBerry API 4.0.0

Method Summary
 String getHeaderField(int n)
          Gets a header field value by index.
 String getHeaderField(String name)
          Returns the value of the named header field.
 int getHeaderFieldInt(String name, int def)
          Returns the value of the named field parsed as a number.
 String getHeaderFieldKey(int n)
          Gets a header field key by index.
 String getRequestMethod()
          Get the current request method. e.g.
 String getRequestURI()
          Returns the requested URI.
 String getResponseProperty(String key)
          Returns the value of the named general response property for this connection.
 String getVersion()
          Returns the HTTP version.
 void setResponseCode(int code)
          Sets the HTTP response status code.
 void setResponseProperty(String key, String value)
          Sets the general response property.
 
Methods inherited from interface javax.microedition.io.ContentConnection
getEncoding, getLength, getType
 
Methods inherited from interface javax.microedition.io.InputConnection
openDataInputStream, openInputStream
 
Methods inherited from interface javax.microedition.io.Connection
close
 
Methods inherited from interface javax.microedition.io.OutputConnection
openDataOutputStream, openOutputStream
 
Methods inherited from interface javax.microedition.io.Connection
close
 



Method Detail

getRequestMethod

String getRequestMethod()
                        throws IOException
Get the current request method. e.g. HEAD, GET, POST The default value is GET.

Returns:
the HTTP request method
Throws:
IOException
Since:
BlackBerry API 4.0.0

getVersion

String getVersion()
                  throws IOException
Returns the HTTP version.

Returns:
Retutn the HTTP version.
Throws:
IOException
Since:
BlackBerry API 4.0.0

getRequestURI

String getRequestURI()
                     throws IOException
Returns the requested URI.

Returns:
Return the requested URI.
Throws:
IOException
Since:
BlackBerry API 4.0.0

getHeaderField

String getHeaderField(int n)
                      throws IOException
Gets a header field value by index.

Parameters:
n - the index of the header field
Returns:
the value of the nth header field or null if the array index is out of range. An empty String is returned if the field does not have a value.
Throws:
IOException - if an error occurred connecting to the client.
Since:
BlackBerry API 4.0.0

getHeaderField

String getHeaderField(String name)
                      throws IOException
Returns the value of the named header field.

Parameters:
name - of a header field.
Returns:
the value of the named header field, or null if there is no such field in the header.
Throws:
IOException - if an error occurred connecting to the client.
Since:
BlackBerry API 4.0.0

getHeaderFieldInt

int getHeaderFieldInt(String name,
                      int def)
                      throws IOException
Returns the value of the named field parsed as a number.

This form of getHeaderField exists because some connection types (e.g., http-ng) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing.

Parameters:
name - the name of the header field.
def - the default value.
Returns:
the value of the named field, parsed as an integer. The def value is returned if the field is missing or malformed.
Throws:
IOException - if an error occurred connecting to the client.
Since:
BlackBerry API 4.0.0

getHeaderFieldKey

String getHeaderFieldKey(int n)
                         throws IOException
Gets a header field key by index.

Parameters:
n - the index of the header field
Returns:
the key of the nth header field or null if the array index is out of range.
Throws:
IOException - if an error occurred connecting to the client.
Since:
BlackBerry API 4.0.0

getResponseProperty

String getResponseProperty(String key)
                           throws IOException
Returns the value of the named general response property for this connection.

Parameters:
key - the keyword by which the response property is known (e.g., "accept").
Returns:
the value of the named general response property for this connection. If there is no key with the specified name then null is returned.
Throws:
IOException
See Also:
HttpServerConnection.setResponseProperty(java.lang.String, java.lang.String)
Since:
BlackBerry API 4.0.0

setResponseProperty

void setResponseProperty(String key,
                         String value)
                         throws IOException
Sets the general response property. If a property with the key already exists, overwrite its value with the new value.

Note: HTTP requires all response properties which can legally have multiple instances with the same key to use a comma-separated list syntax which enables multiple properties to be appended into a single property.

Parameters:
key - the keyword by which the response is known (e.g., "accept").
value - the value associated with it.
Throws:
IOException - is thrown if the connection is in the connected state.
See Also:
HttpServerConnection.getResponseProperty(java.lang.String)
Since:
BlackBerry API 4.0.0

setResponseCode

void setResponseCode(int code)
                     throws IOException
Sets the HTTP response status code.

Parameters:
code - The response code to send to the client.
Throws:
IOException - if an error occurred connecting to the client.
Since:
BlackBerry API 4.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal