mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Use header constants instead of plain text
This commit is contained in:
		
							parent
							
								
									800c075bd1
								
							
						
					
					
						commit
						cc612f8712
					
				| @ -52,7 +52,6 @@ public class OwnCloudClientFactory { | ||||
|     /** Default timeout for establishing a connection */ | ||||
|     public static final int DEFAULT_CONNECTION_TIMEOUT = 60000; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Creates a OwnCloudClient setup for an ownCloud account | ||||
|      * | ||||
|  | ||||
| @ -40,12 +40,14 @@ public class HttpConstants { | ||||
|     public static final String IF_MATCH_HEADER = "If-Match"; | ||||
|     public static final String IF_NONE_MATCH_HEADER = "If-None-Match"; | ||||
|     public static final String CONTENT_TYPE_HEADER = "Content-Type"; | ||||
|     public static final String CONTENT_LENGTH_HEADER = "Content-Length"; | ||||
|     public static final String OC_TOTAL_LENGTH_HEADER = "OC-Total-Length"; | ||||
|     public static final String OC_X_OC_MTIME_HEADER = "X-OC-Mtime"; | ||||
|     public static final String PARAM_SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header"; | ||||
|     public static final String OC_X_REQUEST_ID = "X-Request-ID"; | ||||
|     public static final String LOCATION_HEADER = "Location"; | ||||
|     public static final String LOCATION_HEADER_LOWER = "location"; | ||||
|     public static final String CONTENT_TYPE_URLENCODED_UTF8 = "application/x-www-form-urlencoded; charset=utf-8"; | ||||
| 
 | ||||
|     /*********************************************************************************************************** | ||||
|      ************************************************ STATUS CODES ********************************************* | ||||
|  | ||||
| @ -114,7 +114,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation { | ||||
|                 fos = new FileOutputStream(targetFile); | ||||
|                 long transferred = 0; | ||||
| 
 | ||||
|                 String contentLength = mGet.getResponseHeader("Content-Length"); | ||||
|                 String contentLength = mGet.getResponseHeader(HttpConstants.CONTENT_LENGTH_HEADER); | ||||
|                 long totalToTransfer = | ||||
|                         (contentLength != null | ||||
|                                 && contentLength.length() > 0) | ||||
|  | ||||
| @ -230,7 +230,7 @@ public class CreateRemoteShareOperation extends RemoteOperation { | ||||
| 
 | ||||
|             postMethod.setRequestBody(formBodyBuilder.build()); | ||||
| 
 | ||||
|             postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); | ||||
|             postMethod.setRequestHeader(HttpConstants.CONTENT_TYPE_HEADER, HttpConstants.CONTENT_TYPE_URLENCODED_UTF8); | ||||
|             postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||
| 
 | ||||
|             int status = client.executeHttpMethod(postMethod); | ||||
|  | ||||
| @ -200,14 +200,14 @@ public class UpdateRemoteShareOperation extends RemoteOperation<ShareParserResul | ||||
| 
 | ||||
|             Uri requestUri = client.getBaseUri(); | ||||
|             Uri.Builder uriBuilder = requestUri.buildUpon(); | ||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1)); | ||||
|             uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH); | ||||
|             uriBuilder.appendEncodedPath(Long.toString(mRemoteId)); | ||||
| 
 | ||||
|             PutMethod putMethod = new PutMethod(new URL(uriBuilder.build().toString())); | ||||
| 
 | ||||
|             putMethod.setRequestBody(formBodyBuilder.build()); | ||||
| 
 | ||||
|             putMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); | ||||
|             putMethod.setRequestHeader(HttpConstants.CONTENT_TYPE_HEADER, HttpConstants.CONTENT_TYPE_URLENCODED_UTF8); | ||||
|             putMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||
| 
 | ||||
|             int status = client.executeHttpMethod(putMethod); | ||||
|  | ||||
| @ -46,13 +46,11 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R | ||||
|  * @author David A. Velasco | ||||
|  * @author David González Verdugo | ||||
|  */ | ||||
| 
 | ||||
| public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserAvatarOperation.ResultData> { | ||||
| 
 | ||||
|     private static final String TAG = GetRemoteUserAvatarOperation.class.getSimpleName(); | ||||
| 
 | ||||
|     private static final String NON_OFFICIAL_AVATAR_PATH = "/index.php/avatar/"; | ||||
|     private static final String IF_NONE_MATCH_HEADER = "If-None-Match"; | ||||
| 
 | ||||
|     /** Desired size in pixels of the squared image */ | ||||
|     private int mDimension; | ||||
| @ -63,7 +61,6 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA | ||||
|      */ | ||||
|     private String mCurrentEtag; | ||||
| 
 | ||||
| 
 | ||||
|     public GetRemoteUserAvatarOperation(int dimension, String currentEtag) { | ||||
|         mDimension = dimension; | ||||
|         mCurrentEtag = currentEtag; | ||||
| @ -90,7 +87,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA | ||||
|             if (isSuccess(status)) { | ||||
|                 // find out size of file to read | ||||
|                 int totalToTransfer = 0; | ||||
|                 String contentLength = getMethod.getResponseHeader("Content-Length"); | ||||
|                 String contentLength = getMethod.getResponseHeader(HttpConstants.CONTENT_LENGTH_HEADER); | ||||
| 
 | ||||
|                 if (contentLength != null && contentLength.length() > 0) { | ||||
|                     totalToTransfer = Integer.parseInt(contentLength); | ||||
| @ -98,7 +95,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA | ||||
| 
 | ||||
|                 // find out MIME-type! | ||||
|                 String mimeType; | ||||
|                 String contentType = getMethod.getResponseHeader("Content-Type"); | ||||
|                 String contentType = getMethod.getResponseHeader(HttpConstants.CONTENT_TYPE_HEADER); | ||||
| 
 | ||||
|                 if (contentType == null || !contentType.startsWith("image")) { | ||||
|                     Log_OC.e( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user