java.lang.Object
org.cybergarage.http.HTTPPacket
org.cybergarage.http.HTTPRequest
org.cybergarage.soap.SOAPRequest
org.cybergarage.upnp.control.ControlRequest
org.cybergarage.upnp.control.QueryRequest
Represents a UPnP query request for state variables. Extends ControlRequest to provide functionality for querying the value of state variables.
Constructor Summary
ConstructorsConstructorDescription/////////////////////////////////////////////QueryRequest(HTTPRequest httpReq) Constructs a QueryRequest from an HTTP request.Method Summary
Modifier and TypeMethodDescriptionprivate NodecreateContentNode(StateVariable stateVar) Builds the response content node with the variable's value.Gets the name of the state variable being queried.private NodeGets the variable name node from the query request.post()Posts the query request and returns the response.voidsetRequest(StateVariable stateVar) Sets up the query request for the specified state variable.Methods inherited from class ControlRequest
isActionControl, isQueryControl, setRequestHostModifier and TypeMethodDescriptionbooleanChecks if this is an action control request.booleanChecks if this is a query control request.protected voidsetRequestHost(Service service) Sets the request host and port for the specified service.Methods inherited from class SOAPRequest
getBodyNode, getEnvelopeNode, getSOAPAction, isSOAPAction, postMessage, print, setContent, setEnvelopeNode, setSOAPActionModifier and TypeMethodDescriptionReturn the SOAP body node.Return the SOAP envelope node.Return the SOAP action header value.booleanisSOAPAction(String value) Check if the SOAP action matches the given value.postMessage(String host, int port) Post a SOAP message to the target host and port.voidprint()Writes the request and its root element to the debug log.voidsetContent(Node node) Set the XML content from a node.voidsetEnvelopeNode(Node node) Set the SOAP envelope node.voidsetSOAPAction(String action) Set the SOAP action header.Methods inherited from class HTTPRequest
getFirstLineString, getHeader, getHTTPVersion, getLocalAddress, getLocalPort, getMethod, getParameterList, getParameterValue, getRequestHost, getRequestPort, getSocket, getURI, isGetRequest, isHeadRequest, isKeepAlive, isMethod, isNotifyRequest, isPostRequest, isSOAPAction, isSubscribeRequest, isUnsubscribeRequest, parseRequestLine, post, post, post, read, returnBadRequest, returnOK, returnResponse, set, setBindHost, setMethod, setRequestHost, setRequestPort, setSocket, setURI, setURI, toStringModifier and TypeMethodDescriptionReturns the first line of the HTTP request (method, URI, and version).Returns the complete HTTP header as a string.Returns the HTTP version string for this request.Returns the local address of the underlying socket.intReturns the local port of the underlying socket.Returns the HTTP method.Parses the URI query string and returns the parameters as a ParameterList.getParameterValue(String name) Returns the value of the specified URI query parameter.Returns the request host.intReturns the request port.Returns the HTTPSocket for this request.getURI()Returns the request URI.booleanDetermines if this is a GET request.booleanDetermines if this is a HEAD request.booleanDetermines if this connection should be kept alive.booleanChecks if the HTTP method matches the given string.booleanDetermines if this is a NOTIFY request.booleanDetermines if this is a POST request.booleanChecks if this request has a SOAPAction header.booleanDetermines if this is a SUBSCRIBE request.booleanDetermines if this is an UNSUBSCRIBE request.booleanparseRequestLine(String lineStr) Parses an HTTP request line and extracts method, URI, and version.Posts this HTTP request to the specified host and port with no keep-alive.Posts this HTTP request to the specified host and port.booleanpost(HTTPResponse httpRes) Posts an HTTP response back to the client.booleanread()Reads the HTTP request from the underlying socket.booleanSends an HTTP 400 Bad Request response with no content.booleanreturnOK()Sends an HTTP 200 OK response with no content.booleanreturnResponse(int statusCode) Sends an HTTP response with the specified status code and no content.voidset(HTTPRequest httpReq) Copies the contents of the given HTTP request into this request.voidsetBindHost(String host) I2P - bind HTTP socket to specified local host addressvoidSets the HTTP method (e.g., GET, POST).voidsetRequestHost(String host) Sets the host for this request.voidsetRequestPort(int host) Sets the port for this request.voidsetSocket(HTTPSocket value) Sets the HTTPSocket for this request.voidSets the URI for this HTTP request without relative URL conversion.voidSets the URI for this HTTP request.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.
Constructor Details
QueryRequest
public QueryRequest()/////////////////////////////////////////////QueryRequest
Constructs a QueryRequest from an HTTP request.- Parameters:
httpReq- the HTTP request to wrap
Method Details
getVarNameNode
Gets the variable name node from the query request.- Returns:
- the variable name node, or null if not found
getVarName
Gets the name of the state variable being queried.- Returns:
- the variable name, or empty string if not found
setRequest
Sets up the query request for the specified state variable. Configures the host, SOAP envelope, and action for the query.- Parameters:
stateVar- the state variable to query
createContentNode
Builds the response content node with the variable's value.- Parameters:
stateVar- the state variable being queried- Returns:
- the content node
post
Posts the query request and returns the response.- Returns:
- the query response