[Red5devs] [PATCH 02 of 15] check response code
Mondain
mondain at gmail.com
Tue Aug 26 15:47:55 PDT 2008
Added
On Tue, Aug 26, 2008 at 11:03 AM, mabrek <mabrek at gmail.com> wrote:
> diff -r 3194e68769da -r fea37acdcd8c
> src/org/red5/server/net/rtmpt/RTMPTClientConnector.java
> --- a/src/org/red5/server/net/rtmpt/RTMPTClientConnector.java Mon Jul 14
> 19:35:43 2008 +0400
> +++ b/src/org/red5/server/net/rtmpt/RTMPTClientConnector.java Tue Jul 15
> 13:16:58 2008 +0400
> @@ -24,6 +24,8 @@
>
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpVersion;
> +import org.apache.commons.httpclient.HttpMethod;
> +import org.apache.commons.httpclient.HttpStatus;
> import org.apache.commons.httpclient.params.HttpClientParams;
> import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
> import org.apache.commons.httpclient.methods.PostMethod;
> @@ -102,6 +104,9 @@
>
> post.setRequestEntity(ZERO_REQUEST_ENTITY);
> }
> httpClient.executeMethod(post);
> +
> + checkResponseCode(post);
> +
> byte[] received = post.getResponseBody();
>
> ByteBuffer data =
> ByteBuffer.allocate(received.length);
> @@ -150,6 +155,8 @@
>
> httpClient.executeMethod(openPost);
>
> + checkResponseCode(openPost);
> +
> String response = openPost.getResponseBodyAsString();
> clientId = Integer.parseInt(response
> .substring(0, response.length() - 1));
> @@ -198,6 +205,12 @@
> post.setRequestHeader("Connection", "Keep-Alive");
> post.setRequestHeader("Cache-Control", "no-cache");
> }
> +
> + private void checkResponseCode(HttpMethod method) {
> + if (method.getStatusCode() != HttpStatus.SC_OK) {
> + throw new RuntimeException("Bad HTTP status
> returned: " + method.getStatusLine());
> + }
> + }
>
> public void setStopRequested(boolean stopRequested) {
> this.stopRequested = stopRequested;
>
>
>
> _______________________________________________
> Red5devs mailing list
> Red5devs at osflash.org
> http://osflash.org/mailman/listinfo/red5devs_osflash.org
>
--
http://gregoire.org/
http://osflash.org/red5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5devs_osflash.org/attachments/20080826/1f347ce8/attachment.html
More information about the Red5devs
mailing list