AeroGear Android Library 1.1.0

org.jboss.aerogear.android.impl.http
Class HttpRestProvider

java.lang.Object
  extended by org.jboss.aerogear.android.impl.http.HttpRestProvider
All Implemented Interfaces:
HttpProvider

public final class HttpRestProvider
extends Object
implements HttpProvider

These are tuned for AeroGear, assume the body is String data, and that the headers don't do anything funny.


Constructor Summary
HttpRestProvider(URL url)
           
HttpRestProvider(URL url, Integer timeout)
           
 
Method Summary
 HeaderAndBody delete(String id)
          Issues an HTTP request, consumes the content, and cleans up after itself.
 HeaderAndBody get()
          Issues an HTTP request, consumes the content, and cleans up after itself.
 URL getUrl()
          
 HeaderAndBody post(byte[] data)
          Issues an HTTP request, consumes the content, and cleans up after itself.
 HeaderAndBody post(String data)
          Issues an HTTP request, consumes the content, and cleans up after itself.
 HeaderAndBody put(String id, byte[] data)
          Issues an HTTP request, consumes the content, and cleans up after itself.
 HeaderAndBody put(String id, String data)
          Issues an HTTP request, consumes the content, and cleans up after itself.
 void setDefaultHeader(String headerName, String headerValue)
          Will set a default header value to be used on all calls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRestProvider

public HttpRestProvider(URL url)

HttpRestProvider

public HttpRestProvider(URL url,
                        Integer timeout)
Method Detail

getUrl

public URL getUrl()

Specified by:
getUrl in interface HttpProvider

get

public HeaderAndBody get()
                  throws HttpException
Issues an HTTP request, consumes the content, and cleans up after itself.

Specified by:
get in interface HttpProvider
Returns:
the HeaderAndBody response from the server
Throws:
HttpException - if the http request doesn't return status 200

post

public HeaderAndBody post(String data)
                   throws RuntimeException
Issues an HTTP request, consumes the content, and cleans up after itself.

Specified by:
post in interface HttpProvider
Returns:
the HeaderAndBody response from the server
Throws:
HttpException - if the http request doesn't return status 200
RuntimeException

post

public HeaderAndBody post(byte[] data)
                   throws RuntimeException
Issues an HTTP request, consumes the content, and cleans up after itself.

Specified by:
post in interface HttpProvider
Returns:
the HeaderAndBody response from the server
Throws:
HttpException - if the http request doesn't return status 200
RuntimeException

put

public HeaderAndBody put(String id,
                         String data)
                  throws RuntimeException
Issues an HTTP request, consumes the content, and cleans up after itself.

Specified by:
put in interface HttpProvider
Returns:
the HeaderAndBody response from the server
Throws:
HttpException - if the http request doesn't return status 200
RuntimeException

put

public HeaderAndBody put(String id,
                         byte[] data)
                  throws RuntimeException
Issues an HTTP request, consumes the content, and cleans up after itself.

Specified by:
put in interface HttpProvider
Returns:
the HeaderAndBody response from the server
Throws:
HttpException - if the http request doesn't return status 200
RuntimeException

delete

public HeaderAndBody delete(String id)
                     throws RuntimeException
Issues an HTTP request, consumes the content, and cleans up after itself.

Specified by:
delete in interface HttpProvider
Returns:
the HeaderAndBody response from the server
Throws:
HttpException - if the http request doesn't return status 200
RuntimeException

setDefaultHeader

public void setDefaultHeader(String headerName,
                             String headerValue)
Description copied from interface: HttpProvider
Will set a default header value to be used on all calls

Specified by:
setDefaultHeader in interface HttpProvider
Parameters:
headerName - name
headerValue - value

AeroGear Android Library 1.1.0

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.