@@ -48,9 +48,11 @@ import javax.net.ssl.TrustManagerFactory
4848 * @since 03.03.2017
4949 */
5050@Suppress(" MemberVisibilityCanBePrivate" )
51- abstract class BaseHttpRequest <T >(private val config : CoreConfiguration , private val context : Context , private val method : HttpSender .Method ,
52- private val login : String? , private val password : String? , private val connectionTimeOut : Int , private val socketTimeOut : Int ,
53- private val headers : Map <String , String >? ) : HttpRequest<T> {
51+ abstract class BaseHttpRequest <T >(
52+ private val config : CoreConfiguration , private val context : Context , private val method : HttpSender .Method ,
53+ private val login : String? , private val password : String? , private val connectionTimeOut : Int , private val socketTimeOut : Int ,
54+ private val headers : Map <String , String >?
55+ ) : HttpRequest<T> {
5456 private val senderConfiguration: HttpSenderConfiguration = config.getPluginConfiguration()
5557
5658 /* *
@@ -134,7 +136,9 @@ abstract class BaseHttpRequest<T>(private val config: CoreConfiguration, private
134136 // write output - see http://developer.android.com/reference/java/net/HttpURLConnection.html
135137 connection.requestMethod = method.name
136138 connection.doOutput = true
137- connection.setChunkedStreamingMode(ACRAConstants .DEFAULT_BUFFER_SIZE_IN_BYTES )
139+ if (senderConfiguration.chunked) {
140+ connection.setChunkedStreamingMode(ACRAConstants .DEFAULT_BUFFER_SIZE_IN_BYTES )
141+ }
138142
139143 // Disable ConnectionPooling because otherwise OkHttp ConnectionPool will try to start a Thread on #connect
140144 System .setProperty(" http.keepAlive" , " false" )
@@ -151,19 +155,19 @@ abstract class BaseHttpRequest<T>(private val config: CoreConfiguration, private
151155
152156 @Throws(IOException ::class )
153157 protected fun handleResponse (responseCode : Int , responseMessage : String ) {
154- debug { " Request response : $responseCode : $responseMessage " }
158+ debug { " Request response : $responseCode : $responseMessage " }
155159 if (responseCode >= HttpURLConnection .HTTP_OK && responseCode < HttpURLConnection .HTTP_MULT_CHOICE ) {
156160 // All is good
157- info { " Request received by server" }
161+ info { " Request received by server" }
158162 } else if (responseCode == HttpURLConnection .HTTP_CLIENT_TIMEOUT || responseCode >= HttpURLConnection .HTTP_INTERNAL_ERROR ) {
159163 // timeout or server error. Repeat the request later.
160- warn { " Could not send ACRA Post responseCode=$responseCode message=$responseMessage " }
164+ warn { " Could not send ACRA Post responseCode=$responseCode message=$responseMessage " }
161165 throw IOException (" Host returned error code $responseCode " )
162166 } else if (responseCode >= HttpURLConnection .HTTP_BAD_REQUEST ) {
163167 // Client error. The request must not be repeated. Discard it.
164- warn { " $responseCode : Client error - request will be discarded" }
168+ warn { " $responseCode : Client error - request will be discarded" }
165169 } else {
166- warn { " Could not send ACRA Post - request will be discarded. responseCode=$responseCode message=$responseMessage " }
170+ warn { " Could not send ACRA Post - request will be discarded. responseCode=$responseCode message=$responseMessage " }
167171 }
168172 }
169173
0 commit comments