web/static/javadoc/5.5.0/org/acra/sender/HttpSender.html
org.acra.sender
All Implemented Interfaces:ReportSender
public classHttpSenderextends[Object](http://d.android.com/reference/java/lang/Object.html?is-external=true "class or interface in java.lang")implements[ReportSender](../../../org/acra/sender/ReportSender.html "interface in org.acra.sender")
The ReportSender used by ACRA for http sending
Nested Classes | Modifier and Type | Class and Description |
| --- | --- |
| static class | HttpSender.Method
Available HTTP methods to send data.
|
Constructors | 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.
|
All Methods Instance Methods Concrete Methods | 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](../../../org/acra/config/CoreConfiguration.html "class in org.acra.config")config,
@Nullable[HttpSender.Method](../../../org/acra/sender/HttpSender.Method.html "enum in org.acra.sender")method,
@Nullable[StringFormat](../../../org/acra/data/StringFormat.html "enum in org.acra.data")type)
Create a new HttpSender instance with its destination taken from the supplied config.
Parameters: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](../../../org/acra/config/CoreConfiguration.html "class in org.acra.config")config,
@Nullable[HttpSender.Method](../../../org/acra/sender/HttpSender.Method.html "enum in org.acra.sender")method,
@Nullable[StringFormat](../../../org/acra/data/StringFormat.html "enum in org.acra.data")type,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")formUri)
Create a new HttpPostSender instance with a fixed destination provided as a parameter. Configuration changes to the formUri are not applied.
Parameters: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](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")username,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")password)
Set credentials for this HttpSender that override (if present) the ones set globally.
Parameters:username - The username to set for HTTP Basic Auth.password - The password to set for HTTP Basic Auth.
-
public void send(@NonNull[Context](http://d.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,
@NonNull[CrashReportData](../../../org/acra/data/CrashReportData.html "class in org.acra.data")report)
throws[ReportSenderException](../../../org/acra/sender/ReportSenderException.html "class in org.acra.sender")
Description copied from interface: ReportSender
Send crash report data.
Method will be called from the LegacySenderService.
Specified by:send in interface ReportSenderParameters:context - Android Context in which to send the crash report.report - Stores key/value pairs for each report field.Throws: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](../../../org/acra/config/CoreConfiguration.html "class in org.acra.config")configuration,
@NonNull[Context](http://d.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,
@NonNull[HttpSender.Method](../../../org/acra/sender/HttpSender.Method.html "enum in org.acra.sender")method,
@NonNull[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")contentType,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")login,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")password,
int connectionTimeOut,
int socketTimeOut,
@Nullable[Map](http://d.android.com/reference/java/util/Map.html?is-external=true "class or interface in java.util")<[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> headers,
@NonNull[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")content,
@NonNull[URL](http://d.android.com/reference/java/net/URL.html?is-external=true "class or interface in java.net")url,
@NonNull[List](http://d.android.com/reference/java/util/List.html?is-external=true "class or interface in java.util")<[Uri](http://d.android.com/reference/android/net/Uri.html?is-external=true "class or interface in android.net")> attachments)
throws[IOException](http://d.android.com/reference/java/io/IOException.html?is-external=true "class or interface in java.io")
Throws:IOException
-
protected void sendWithoutAttachments(@NonNull[CoreConfiguration](../../../org/acra/config/CoreConfiguration.html "class in org.acra.config")configuration,
@NonNull[Context](http://d.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,
@NonNull[HttpSender.Method](../../../org/acra/sender/HttpSender.Method.html "enum in org.acra.sender")method,
@NonNull[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")contentType,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")login,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")password,
int connectionTimeOut,
int socketTimeOut,
@Nullable[Map](http://d.android.com/reference/java/util/Map.html?is-external=true "class or interface in java.util")<[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> headers,
@NonNull[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")content,
@NonNull[URL](http://d.android.com/reference/java/net/URL.html?is-external=true "class or interface in java.net")url)
throws[IOException](http://d.android.com/reference/java/io/IOException.html?is-external=true "class or interface in java.io")
Throws:IOException
-
protected void postMultipart(@NonNull[CoreConfiguration](../../../org/acra/config/CoreConfiguration.html "class in org.acra.config")configuration,
@NonNull[Context](http://d.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,
@NonNull[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")contentType,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")login,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")password,
int connectionTimeOut,
int socketTimeOut,
@Nullable[Map](http://d.android.com/reference/java/util/Map.html?is-external=true "class or interface in java.util")<[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> headers,
@NonNull[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")content,
@NonNull[URL](http://d.android.com/reference/java/net/URL.html?is-external=true "class or interface in java.net")url,
@NonNull[List](http://d.android.com/reference/java/util/List.html?is-external=true "class or interface in java.util")<[Uri](http://d.android.com/reference/android/net/Uri.html?is-external=true "class or interface in android.net")> attachments)
throws[IOException](http://d.android.com/reference/java/io/IOException.html?is-external=true "class or interface in java.io")
Throws:IOException
-
protected void putAttachment(@NonNull[CoreConfiguration](../../../org/acra/config/CoreConfiguration.html "class in org.acra.config")configuration,
@NonNull[Context](http://d.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")login,
@Nullable[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")password,
int connectionTimeOut,
int socketTimeOut,
@Nullable[Map](http://d.android.com/reference/java/util/Map.html?is-external=true "class or interface in java.util")<[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> headers,
@NonNull[URL](http://d.android.com/reference/java/net/URL.html?is-external=true "class or interface in java.net")url,
@NonNull[Uri](http://d.android.com/reference/android/net/Uri.html?is-external=true "class or interface in android.net")attachment)
throws[IOException](http://d.android.com/reference/java/io/IOException.html?is-external=true "class or interface in java.io")
Throws:IOException
-
@NonNull
protected[String](http://d.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")convertToString([CrashReportData](../../../org/acra/data/CrashReportData.html "class in org.acra.data")report,
@NonNull[StringFormat](../../../org/acra/data/StringFormat.html "enum in org.acra.data")format)
throws[Exception](http://d.android.com/reference/java/lang/Exception.html?is-external=true "class or interface in java.lang")
Convert a report to string
Parameters:report - the report to convertformat - the format to convert toReturns:a string representation of the reportThrows:Exception - if conversion failed