public class HttpSender extends Object implements ReportSender
ReportSender
used by ACRA for http sendingModifier and Type | Class and Description |
---|---|
static class |
HttpSender.Method
Available HTTP methods to send data.
|
Constructor and Description |
---|
HttpSender(CoreConfiguration config,
HttpSender.Method method,
StringFormat type)
Create a new HttpSender instance with its destination taken from the supplied config.
|
HttpSender(CoreConfiguration config,
HttpSender.Method method,
StringFormat type,
String formUri)
Create a new HttpPostSender instance with a fixed destination provided as
a parameter.
|
Modifier and Type | Method and Description |
---|---|
protected String |
convertToString(CrashReportData report,
StringFormat format)
Convert a report to string
|
protected void |
postMultipart(CoreConfiguration configuration,
Context context,
String contentType,
String login,
String password,
int connectionTimeOut,
int socketTimeOut,
Map<String,String> headers,
String content,
URL url,
List<Uri> attachments) |
protected void |
putAttachment(CoreConfiguration configuration,
Context context,
String login,
String password,
int connectionTimeOut,
int socketTimeOut,
Map<String,String> headers,
URL url,
Uri attachment) |
void |
send(Context context,
CrashReportData report)
Send crash report data.
|
protected void |
sendHttpRequests(CoreConfiguration configuration,
Context context,
HttpSender.Method method,
String contentType,
String login,
String password,
int connectionTimeOut,
int socketTimeOut,
Map<String,String> headers,
String content,
URL url,
List<Uri> attachments) |
protected void |
sendWithoutAttachments(CoreConfiguration configuration,
Context context,
HttpSender.Method method,
String contentType,
String login,
String password,
int connectionTimeOut,
int socketTimeOut,
Map<String,String> headers,
String content,
URL url) |
void |
setBasicAuth(String username,
String password)
Set credentials for this HttpSender that override (if present) the ones set globally.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
requiresForeground, send
public HttpSender(@NonNull CoreConfiguration config, @Nullable HttpSender.Method method, @Nullable StringFormat type)
Create a new HttpSender instance with its destination taken from the supplied config.
config
- AcraConfig declaring themethod
- HTTP HttpSender.Method
to be used to send data. Currently only HttpSender.Method.POST
and HttpSender.Method.PUT
are available.
If HttpSender.Method.PUT
is used, the ReportField.REPORT_ID
is appended to the formUri to be compliant with RESTful APIs.type
- StringFormat
of encoding used to send the report body.
StringFormat.KEY_VALUE_LIST
is a simple Key/Value pairs list as defined by the application/x-www-form-urlencoded mime type.public HttpSender(@NonNull CoreConfiguration config, @Nullable HttpSender.Method method, @Nullable StringFormat type, @Nullable String formUri)
Create a new HttpPostSender instance with a fixed destination provided as a parameter. Configuration changes to the formUri are not applied.
config
- AcraConfig declaring themethod
- HTTP HttpSender.Method
to be used to send data. Currently only HttpSender.Method.POST
and HttpSender.Method.PUT
are available.
If HttpSender.Method.PUT
is used, the ReportField.REPORT_ID
is appended to the formUri to be compliant with RESTful APIs.type
- StringFormat
of encoding used to send the report body.
StringFormat.KEY_VALUE_LIST
is a simple Key/Value pairs list as defined by the application/x-www-form-urlencoded mime type.formUri
- The URL of your server-side crash report collection script.public void setBasicAuth(@Nullable String username, @Nullable String password)
Set credentials for this HttpSender that override (if present) the ones set globally.
username
- The username to set for HTTP Basic Auth.password
- The password to set for HTTP Basic Auth.public void send(@NonNull Context context, @NonNull CrashReportData report) throws ReportSenderException
ReportSender
Method will be called from the LegacySenderService
.
send
in interface ReportSender
context
- Android Context in which to send the crash report.report
- Stores key/value pairs for each report field.ReportSenderException
- If anything goes fatally wrong during the handling of crash data, you can (should) throw a ReportSenderException
with a custom message.protected void sendHttpRequests(@NonNull CoreConfiguration configuration, @NonNull Context context, @NonNull HttpSender.Method method, @NonNull String contentType, @Nullable String login, @Nullable String password, int connectionTimeOut, int socketTimeOut, @Nullable Map<String,String> headers, @NonNull String content, @NonNull URL url, @NonNull List<Uri> attachments) throws IOException
IOException
protected void sendWithoutAttachments(@NonNull CoreConfiguration configuration, @NonNull Context context, @NonNull HttpSender.Method method, @NonNull String contentType, @Nullable String login, @Nullable String password, int connectionTimeOut, int socketTimeOut, @Nullable Map<String,String> headers, @NonNull String content, @NonNull URL url) throws IOException
IOException
protected void postMultipart(@NonNull CoreConfiguration configuration, @NonNull Context context, @NonNull String contentType, @Nullable String login, @Nullable String password, int connectionTimeOut, int socketTimeOut, @Nullable Map<String,String> headers, @NonNull String content, @NonNull URL url, @NonNull List<Uri> attachments) throws IOException
IOException
protected void putAttachment(@NonNull CoreConfiguration configuration, @NonNull Context context, @Nullable String login, @Nullable String password, int connectionTimeOut, int socketTimeOut, @Nullable Map<String,String> headers, @NonNull URL url, @NonNull Uri attachment) throws IOException
IOException
@NonNull protected String convertToString(CrashReportData report, @NonNull StringFormat format) throws Exception
report
- the report to convertformat
- the format to convert toException
- if conversion failed