|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpl.mbdev.openstage.push.HttpRequest
public abstract class HttpRequest
Enables easier formulation and execution of HTTP requests.
Copyright 2011 Mateusz Bysiek, mb@mbdev.pl, http://mbdev.pl/ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Field Summary | |
---|---|
private java.io.BufferedReader |
bufferedReader
Buffer for the reader of the input stream. |
private java.net.HttpURLConnection |
connection
HTTP connection. |
private java.io.InputStream |
in
Input stream. |
protected java.io.OutputStream |
out
Output stream. |
private RequestParameters |
parameters
Parameters parameters of this request. |
private java.io.Reader |
reader
Reader for the input stream. |
private java.io.OutputStreamWriter |
writer
Writer for the output stream. |
Constructor Summary | |
---|---|
HttpRequest(RequestParameters parameters)
Creates new generic HTTP request with given parameters. |
Method Summary | |
---|---|
protected void |
connectTo(java.net.URL targetAddress,
java.lang.String method)
|
void |
disconnect()
Disconnects from the remote server. |
protected void |
endInput()
Closes the input stream. |
protected void |
endOutput()
|
protected RequestParameters |
getParameters()
Returns the request parameters. |
protected abstract java.lang.String |
getResponse(java.net.URL targetAddress)
Provides default implementation for HTTP request execution. |
protected abstract boolean |
sendTo(java.net.URL targetAddress)
Sends the push to a given URL. |
protected java.io.BufferedReader |
startInput()
Starts input, opens input stream. |
protected java.io.OutputStreamWriter |
startOutput(java.lang.String encoding)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final RequestParameters parameters
private java.net.HttpURLConnection connection
protected java.io.OutputStream out
private java.io.OutputStreamWriter writer
private java.io.InputStream in
private java.io.Reader reader
private java.io.BufferedReader bufferedReader
Constructor Detail |
---|
public HttpRequest(RequestParameters parameters)
parameters
- parameters of this requestMethod Detail |
---|
protected final RequestParameters getParameters()
protected void connectTo(java.net.URL targetAddress, java.lang.String method) throws java.io.IOException
targetAddress
- target addressmethod
- HTTP method: GET, POST, ...
java.io.IOException
- when connection cannot be establishedprotected java.io.OutputStreamWriter startOutput(java.lang.String encoding) throws java.io.UnsupportedEncodingException, java.io.IOException
encoding
- character encoding, for example 'UTF-8'
java.io.UnsupportedEncodingException
- when given encoding is not supported by the server.
java.io.IOException
- when output streams cannot be openedprotected void endOutput() throws java.io.IOException
java.io.IOException
- when output streams cannot be closedprotected java.io.BufferedReader startInput() throws java.io.IOException
java.io.IOException
- when the input stream cannot be openedprotected void endInput() throws java.io.IOException
java.io.IOException
- when the input stream cannot be closedpublic void disconnect()
protected abstract java.lang.String getResponse(java.net.URL targetAddress) throws java.io.IOException
targetAddress
- URL of the target to which this request will be sent
java.io.IOException
- thrown when the given URL caused a connection error, there was a protocol
exception or data transfer was interruptedprotected abstract boolean sendTo(java.net.URL targetAddress) throws java.io.IOException
targetAddress
- URL of the target to which this request will be sent
java.io.IOException
- thrown when the given URL caused a connection error, there was a protocol
exception or data transfer was interrupted
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |