java.lang.Object
org.cybergarage.http.HTTPPacket
org.cybergarage.http.HTTPResponse
org.cybergarage.soap.SOAPResponse
org.cybergarage.upnp.control.ControlResponse
- Direct Known Subclasses:
ActionResponse, QueryResponse
Represents a UPnP control response. Extends SOAPResponse to provide UPnP-specific error handling and fault response functionality.
Field Summary
Modifier and TypeFieldDescriptionstatic final StringDefault fault code for UPnP errorsstatic final StringDefault fault string for UPnP errorsprivate UPnPStatus/////////////////////////////////////////////Constructor Summary
ConstructorsConstructorDescription/////////////////////////////////////////////ControlResponse(SOAPResponse soapRes) Constructs a ControlResponse from a SOAP response.Method Summary
Modifier and TypeMethodDescriptionprivate NodecreateFaultResponseNode(int errCode) Builds a SOAP fault element with a default description.private NodecreateFaultResponseNode(int errCode, String errDescr) Builds the SOAP fault node for an error.Gets the complete UPnP error status from the response.intGets the UPnP error code from the response.private NodeGets the UPnP error code node.Gets the UPnP error description from the response.private NodeGets the UPnP error description node.private NodeGets the UPnP error node from the fault detail.voidsetFaultResponse(int errCode) Sets a fault response with the specified error code.voidsetFaultResponse(int errCode, String errDescr) Sets a fault response with the specified error code and description.Methods inherited from class SOAPResponse
getBodyNode, getEnvelopeNode, getFaultActor, getFaultActorNode, getFaultCode, getFaultCodeNode, getFaultDetailNode, getFaultNode, getFaultString, getFaultStringNode, getMethodResponseNode, print, setContent, setEnvelopeNodeModifier and TypeMethodDescriptionGet the SOAP body node.Get the SOAP envelope node.Get the SOAP fault actor string.Get the SOAP fault actor node.Get the SOAP fault code string.Get the SOAP fault code node.Get the SOAP fault detail node.Get the SOAP fault node.Get the SOAP fault string.Get the SOAP fault string node.getMethodResponseNode(String name) Get the method response node for the given name.voidprint()Writes the response to the debug log, as text or as its root element.voidsetContent(Node node) Set the content from an XML node.voidsetEnvelopeNode(Node node) Set the SOAP envelope node.Methods inherited from class HTTPResponse
getHeader, getStatusCode, getStatusLineString, isSuccessful, setStatusCode, toStringModifier and TypeMethodDescriptionReturn the full header string for this HTTP response.intGets the HTTP status code of this response.Gets the status line string of this HTTP response.booleanChecks if this response has a successful status code.voidsetStatusCode(int code) Sets the HTTP status code of this response.toString()/////////////////////////////////////////////Methods inherited from class HTTPPacket
addHeader, addHeader, clearHeaders, getCacheControl, getCharSet, getConnection, getContent, getContentInputStream, getContentLanguage, getContentLength, getContentRange, getContentRangeFirstPosition, getContentRangeInstanceLength, getContentRangeLastPosition, getContentString, getContentType, getDate, getFirstLine, getFirstLineToken, getHeader, getHeader, getHeaderString, getHeaderValue, getHost, getIntegerHeaderValue, getLongHeaderValue, getNHeaders, getServer, getStringHeaderValue, getStringHeaderValue, getTransferEncoding, getVersion, hasConnection, hasContent, hasContentInputStream, hasContentRange, hasFirstLine, hasHeader, hasTransferEncoding, init, isChunked, isCloseConnection, isKeepAliveConnection, read, set, set, set, set, setCacheControl, setCacheControl, setCacheControl, setConnection, setContent, setContent, setContent, setContent, setContentInputStream, setContentLanguage, setContentLength, setContentRange, setContentType, setDate, setHeader, setHeader, setHeader, setHeader, setHost, setIntegerHeader, setLongHeader, setServer, setStringHeader, setStringHeader, setTransferEncoding, setVersionModifier and TypeMethodDescriptionvoidAdds a header with the specified name and value.voidaddHeader(HTTPHeader header) Adds a header to this HTTP packet.voidClears all headers from this HTTP packet.Get the Cache-Control header value.Gets the character set from the Content-Type header.Gets the Connection header value.byte[]Gets the content of this HTTP packet.Gets the content input stream.Gets the Content-Language header value.longGets the content length from the Content-Length header.long[]Gets the content range values as an array.longGet the first position from the content range.longGet the instance length from the content range.longGet the last position from the content range.Gets the content of this HTTP packet as a string.Gets the Content-Type header value.getDate()Get the Date header value.protected StringGets the first line of the HTTP packet.protected StringgetFirstLineToken(int num) Gets a specific token from the first line using HTTP request line delimiters.getHeader(int n) Gets the header at the specified index.Gets the header with the specified name, ignoring case.Gets all headers as a formatted string.getHeaderValue(String name) Gets the value of a header by name.getHost()Get the Host header value.intgetIntegerHeaderValue(String name) Gets an integer header value by name.longgetLongHeaderValue(String name) Gets a long header value by name.intGets the number of headers in this HTTP packet.Get the Server header value.getStringHeaderValue(String name) Gets a string header value, stripping double quotes if present.getStringHeaderValue(String name, String startWidth, String endWidth) Gets a string header value, stripping the specified delimiters if present.Get the Transfer-Encoding header value.Gets the HTTP version of this packet.booleanChecks if the Connection header is set.booleanChecks if this HTTP packet has content.booleanChecks if a content input stream has been set.booleanChecks if the Content-Range or Range header is set.booleanChecks if the first line of the HTTP packet has been set.booleanChecks if a header with the specified name exists.booleanCheck if the Transfer-Encoding header is set.voidinit()Initializes the HTTP packet to empty state.booleanCheck if the content is chunked.booleanChecks if the Connection header is set to close.booleanChecks if the Connection header is set to keep-alive.booleanread(HTTPSocket httpSock) Reads and parses HTTP packet from a socket.protected booleanset(InputStream in) Parses HTTP packet data from an input stream including content.protected booleanset(InputStream in, boolean onlyHeaders) Parses HTTP packet data from an input stream.protected voidset(HTTPPacket httpPacket) Copies all data from another HTTP packet to this packet.protected booleanset(HTTPSocket httpSock) Parses HTTP packet data from an HTTP socket.voidsetCacheControl(int value) Set the Cache-Control header with a max-age value.voidsetCacheControl(String directive) Set the Cache-Control header.voidsetCacheControl(String directive, int value) Set the Cache-Control header with a directive and value.voidsetConnection(String value) Sets the Connection header.voidsetContent(byte[] data) Sets the content of this HTTP packet.voidsetContent(byte[] data, boolean updateWithContentLength) Sets the content of this HTTP packet.voidsetContent(String data) Sets the content of this HTTP packet from a string.voidsetContent(String data, boolean updateWithContentLength) Sets the content of this HTTP packet from a string.voidSets the content input stream.voidsetContentLanguage(String code) Sets the Content-Language header.voidsetContentLength(long len) Sets the Content-Length header.voidsetContentRange(long firstPos, long lastPos, long length) Sets the Content-Range header.voidsetContentType(String type) Sets the Content-Type header.voidSet the Date header.voidSets the value of a header from an integer.voidSets the value of a header from a long.voidSets the value of a header.voidsetHeader(HTTPHeader header) Sets the value of a header from an HTTP header object.voidSet the Host header.voidsetIntegerHeader(String name, int value) Sets an integer header value.voidsetLongHeader(String name, long value) Sets a long header value.voidSet the Server header.voidsetStringHeader(String name, String value) Sets a string header value, wrapping it with double quotes if not already wrapped.voidsetStringHeader(String name, String value, String startWidth, String endWidth) Sets a string header value, wrapping it with the specified delimiters if not already wrapped.voidsetTransferEncoding(String value) Set the Transfer-Encoding header.voidsetVersion(String ver) Sets the HTTP version for this packet.
Field Details
FAULT_CODE
Default fault code for UPnP errors- See Also:
FAULT_STRING
Default fault string for UPnP errors- See Also:
upnpErr
/////////////////////////////////////////////
Constructor Details
ControlResponse
public ControlResponse()/////////////////////////////////////////////ControlResponse
Constructs a ControlResponse from a SOAP response.- Parameters:
soapRes- the SOAP response to wrap
Method Details
setFaultResponse
Sets a fault response with the specified error code and description.- Parameters:
errCode- the UPnP error codeerrDescr- the error description
setFaultResponse
public void setFaultResponse(int errCode) Sets a fault response with the specified error code. The error description is automatically generated from the error code.- Parameters:
errCode- the UPnP error code
createFaultResponseNode
createFaultResponseNode
Builds a SOAP fault element with a default description.- Parameters:
errCode- the UPnP error number- Returns:
- the fault node
getUPnPErrorNode
Gets the UPnP error node from the fault detail.- Returns:
- the UPnP error node, or null if not found
getUPnPErrorCodeNode
Gets the UPnP error code node.- Returns:
- the error code node, or null if not found
getUPnPErrorDescriptionNode
Gets the UPnP error description node.- Returns:
- the error description node, or null if not found
getUPnPErrorCode
public int getUPnPErrorCode()Gets the UPnP error code from the response.- Returns:
- the error code, or -1 if not found or invalid
getUPnPErrorDescription
Gets the UPnP error description from the response.- Returns:
- the error description, or empty string if not found
getUPnPError
Gets the complete UPnP error status from the response.- Returns:
- a UPnPStatus object containing the error code and description