public abstract class BaseHttpRequest<T> extends Object implements HttpRequest<T>
| Constructor and Description |
|---|
BaseHttpRequest(CoreConfiguration config,
Context context,
HttpSender.Method method,
String login,
String password,
int connectionTimeOut,
int socketTimeOut,
Map<String,String> headers) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configureHeaders(HttpURLConnection connection,
String login,
String password,
Map<String,String> customHeaders,
T t) |
protected void |
configureHttps(HttpsURLConnection connection) |
protected void |
configureTimeouts(HttpURLConnection connection,
int connectionTimeOut,
int socketTimeOut) |
protected HttpURLConnection |
createConnection(URL url) |
protected abstract String |
getContentType(Context context,
T t) |
protected void |
handleResponse(int responseCode,
String responseMessage) |
void |
send(URL url,
T content)
Sends to a URL.
|
protected abstract void |
write(OutputStream outputStream,
T content) |
protected void |
writeContent(HttpURLConnection connection,
HttpSender.Method method,
T content) |
public BaseHttpRequest(@NonNull
CoreConfiguration config,
@NonNull
Context context,
@NonNull
HttpSender.Method method,
@Nullable
String login,
@Nullable
String password,
int connectionTimeOut,
int socketTimeOut,
@Nullable
Map<String,String> headers)
public void send(@NonNull
URL url,
@NonNull
T content)
throws IOException
send in interface HttpRequest<T>url - URL to which to send.content - content to send.IOException - if the data cannot be sent.@NonNull protected HttpURLConnection createConnection(@NonNull URL url) throws IOException
IOExceptionprotected void configureHttps(@NonNull
HttpsURLConnection connection)
throws GeneralSecurityException
GeneralSecurityExceptionprotected void configureTimeouts(@NonNull
HttpURLConnection connection,
int connectionTimeOut,
int socketTimeOut)
protected void configureHeaders(@NonNull
HttpURLConnection connection,
@Nullable
String login,
@Nullable
String password,
@Nullable
Map<String,String> customHeaders,
@NonNull
T t)
throws IOException
IOException@NonNull protected abstract String getContentType(@NonNull Context context, @NonNull T t)
protected void writeContent(@NonNull
HttpURLConnection connection,
@NonNull
HttpSender.Method method,
@NonNull
T content)
throws IOException
IOExceptionprotected abstract void write(OutputStream outputStream, @NonNull T content) throws IOException
IOExceptionprotected void handleResponse(int responseCode,
String responseMessage)
throws IOException
IOException