@@ -50,12 +50,12 @@ public class DefaultHttpProvider implements IHttpProvider {
5050 /**
5151 * The content type header
5252 */
53- static final String ContentTypeHeaderName = "Content-Type" ;
53+ static final String CONTENT_TYPE_HEADER_NAME = "Content-Type" ;
5454
5555 /**
5656 * The content type for json responses
5757 */
58- static final String JsonContentType = "application/json" ;
58+ static final String JSON_CONTENT_TYPE = "application/json" ;
5959
6060 /**
6161 * The serializer.
@@ -102,6 +102,7 @@ public DefaultHttpProvider(final ISerializer serializer,
102102
103103 /**
104104 * Gets the serializer for this http provider.
105+ *
105106 * @return The serializer for this provider.
106107 */
107108 @ Override
@@ -125,7 +126,7 @@ public <Result, Body> void send(final IHttpRequest request,
125126 final Body serializable ) {
126127 final IProgressCallback <Result > progressCallback ;
127128 if (callback instanceof IProgressCallback ) {
128- progressCallback = (IProgressCallback <Result >)callback ;
129+ progressCallback = (IProgressCallback <Result >) callback ;
129130 } else {
130131 progressCallback = null ;
131132 }
@@ -135,10 +136,10 @@ public <Result, Body> void send(final IHttpRequest request,
135136 public void run () {
136137 try {
137138 mExecutors .performOnForeground (sendRequestInternal (request ,
138- resultClass ,
139- serializable ,
140- progressCallback ),
141- callback );
139+ resultClass ,
140+ serializable ,
141+ progressCallback ),
142+ callback );
142143 } catch (final ClientException e ) {
143144 mExecutors .performOnForeground (e , callback );
144145 }
@@ -211,13 +212,13 @@ private <Result, Body> Result sendRequestInternal(final IHttpRequest request,
211212 } else if (serializable instanceof byte []) {
212213 mLogger .logDebug ("Sending byte[] as request body" );
213214 bytesToWrite = (byte []) serializable ;
214- connection .addRequestHeader (ContentTypeHeaderName , binaryContentType );
215+ connection .addRequestHeader (CONTENT_TYPE_HEADER_NAME , binaryContentType );
215216 connection .setContentLength (bytesToWrite .length );
216217 } else {
217218 mLogger .logDebug ("Sending " + serializable .getClass ().getName () + " as request body" );
218219 final String serializeObject = mSerializer .serializeObject (serializable );
219220 bytesToWrite = serializeObject .getBytes ();
220- connection .addRequestHeader (ContentTypeHeaderName , JsonContentType );
221+ connection .addRequestHeader (CONTENT_TYPE_HEADER_NAME , JSON_CONTENT_TYPE );
221222 connection .setContentLength (bytesToWrite .length );
222223 }
223224
@@ -235,24 +236,24 @@ private <Result, Body> Result sendRequestInternal(final IHttpRequest request,
235236 writtenSoFar = writtenSoFar + toWrite ;
236237 if (progress != null ) {
237238 mExecutors .performOnForeground (writtenSoFar , bytesToWrite .length ,
238- progress );
239+ progress );
239240 }
240- } while (toWrite > 0 );
241+ } while (toWrite > 0 );
241242 bos .close ();
242243 }
243244
244245 mLogger .logDebug (String .format ("Response code %d, %s" ,
245- connection .getResponseCode (),
246- connection .getResponseMessage ()));
246+ connection .getResponseCode (),
247+ connection .getResponseMessage ()));
247248 if (connection .getResponseCode () >= httpClientErrorResponseCode
248- && !isAsyncOperation (resultClass )) {
249+ && !isAsyncOperation (resultClass )) {
249250 mLogger .logDebug ("Handling error response" );
250251 in = connection .getInputStream ();
251252 handleErrorResponse (request , serializable , connection );
252253 }
253254
254255 if (connection .getResponseCode () == httpNoBodyResponseCode
255- || connection .getResponseCode () == httpNotModified ) {
256+ || connection .getResponseCode () == httpNotModified ) {
256257 mLogger .logDebug ("Handling response with no body" );
257258 return null ;
258259 }
@@ -273,16 +274,16 @@ private <Result, Body> Result sendRequestInternal(final IHttpRequest request,
273274 }
274275 in = new BufferedInputStream (connection .getInputStream ());
275276 final Result result = handleJsonResponse (in , resultClass );
276- ((AsyncOperationStatus )result ).seeOther = connection .getHeaders ().get ("Location" );
277+ ((AsyncOperationStatus ) result ).seeOther = connection .getHeaders ().get ("Location" );
277278 return result ;
278279 }
279280
280281 in = new BufferedInputStream (connection .getInputStream ());
281282
282283 final Map <String , String > headers = connection .getHeaders ();
283284
284- final String contentType = headers .get (ContentTypeHeaderName );
285- if (contentType .contains (JsonContentType )) {
285+ final String contentType = headers .get (CONTENT_TYPE_HEADER_NAME );
286+ if (contentType .contains (JSON_CONTENT_TYPE )) {
286287 mLogger .logDebug ("Response json" );
287288 return handleJsonResponse (in , resultClass );
288289 } else {
@@ -306,15 +307,16 @@ private <Result, Body> Result sendRequestInternal(final IHttpRequest request,
306307 throw ex ;
307308 } catch (final Exception ex ) {
308309 final ClientException clientException = new ClientException ("Error during http request" ,
309- ex ,
310- OneDriveErrorCodes .GeneralException );
310+ ex ,
311+ OneDriveErrorCodes .GeneralException );
311312 mLogger .logError ("Error during http request" , clientException );
312313 throw clientException ;
313314 }
314315 }
315316
316317 /**
317318 * Checks if the given class is an async operation.
319+ *
318320 * @param resultClass The class to check.
319321 * @return true if the class is an async operation.
320322 */
@@ -335,11 +337,12 @@ private <Body> void handleErrorResponse(final IHttpRequest request,
335337 final IConnection connection )
336338 throws IOException {
337339 throw OneDriveServiceException .createFromConnection (request , serializable , mSerializer ,
338- connection );
340+ connection );
339341 }
340342
341343 /**
342344 * Handles the cause where the response is a binary stream.
345+ *
343346 * @param in The input stream from the response.
344347 * @return The input stream to return to the caller.
345348 */
@@ -365,6 +368,7 @@ private <Result> Result handleJsonResponse(final InputStream in, final Class<Res
365368
366369 /**
367370 * Sets the connection factory for this provider.
371+ *
368372 * @param factory The new factory.
369373 */
370374 void setConnectionFactory (final IConnectionFactory factory ) {
@@ -373,6 +377,7 @@ void setConnectionFactory(final IConnectionFactory factory) {
373377
374378 /**
375379 * Reads in a stream and converts it into a string.
380+ *
376381 * @param input The response body stream.
377382 * @return The string result.
378383 */
0 commit comments