protected static String canonicalizeHttpRequest ( final java . net . URL address , final String accountName , final String method , final String contentType , final long contentLength , final String date , final HttpURLConnection conn ) throws StorageException { // The first element should be the Method of the request. // I.e. GET, POST, PUT, or HEAD. final StringBuilder canonicalizedString = new StringBuilder ( ExpectedBlobQueueCanonicalizedStringLength ) ; canonicalizedString . append ( conn . getRequestMethod ( ) ) ; // The next elements are // If any element is missing it may be empty. appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . CONTENT_ENCODING ) ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . CONTENT_LANGUAGE ) ) ; appendCanonicalizedElement ( canonicalizedString , contentLength <= 0 ? Constants . EMPTY_STRING : String . valueOf ( contentLength ) ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . CONTENT_MD5 ) ) ; appendCanonicalizedElement ( canonicalizedString , contentType != null ? contentType : Constants . EMPTY_STRING ) ; final String dateString = Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . DATE ) ; // If x-ms-date header exists, Date should be empty string appendCanonicalizedElement ( canonicalizedString , dateString . equals ( Constants . EMPTY_STRING ) ? date : Constants . EMPTY_STRING ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . IF_MODIFIED_SINCE ) ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . IF_MATCH ) ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . IF_NONE_MATCH ) ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . IF_UNMODIFIED_SINCE ) ) ; appendCanonicalizedElement ( canonicalizedString , Utility . getStandardHeaderValue ( conn , Constants . HeaderConstants . RANGE ) ) ; addCanonicalizedHeaders ( conn , canonicalizedString ) ; appendCanonicalizedElement ( canonicalizedString , getCanonicalizedResource ( address , accountName ) ) ; return canonicalizedString . toString ( ) ; }
Constructs a canonicalized string from the request s headers that will be used to construct the signature string for signing a Blob or Queue service request under the Shared Key Full authentication scheme .