@@ -298,8 +298,18 @@ public void ModifyResponse(AlibabaCloud.GatewaySpi.Models.InterceptorContext con
298298 AlibabaCloud . GatewaySpi . Models . InterceptorContext . InterceptorContextResponse response = context . Response ;
299299 if ( AlibabaCloud . TeaUtil . Common . Is4xx ( response . StatusCode ) || AlibabaCloud . TeaUtil . Common . Is5xx ( response . StatusCode ) )
300300 {
301- object _res = AlibabaCloud . TeaUtil . Common . ReadAsJSON ( response . Body ) ;
302- Dictionary < string , object > err = AlibabaCloud . TeaUtil . Common . AssertAsMap ( _res ) ;
301+ Dictionary < string , object > err = new Dictionary < string , object > ( ) { } ;
302+ if ( ! AlibabaCloud . TeaUtil . Common . IsUnset ( response . Headers . Get ( "content-type" ) ) && AlibabaCloud . DarabonbaString . StringUtil . Contains ( response . Headers . Get ( "content-type" ) , "text/xml" ) )
303+ {
304+ string _str = AlibabaCloud . TeaUtil . Common . ReadAsString ( response . Body ) ;
305+ Dictionary < string , object > respMap = AlibabaCloud . TeaXML . Client . ParseXml ( _str , null ) ;
306+ err = AlibabaCloud . TeaUtil . Common . AssertAsMap ( respMap . Get ( "Error" ) ) ;
307+ }
308+ else
309+ {
310+ object _res = AlibabaCloud . TeaUtil . Common . ReadAsJSON ( response . Body ) ;
311+ err = AlibabaCloud . TeaUtil . Common . AssertAsMap ( _res ) ;
312+ }
303313 object requestId = DefaultAny ( err . Get ( "RequestId" ) , err . Get ( "requestId" ) ) ;
304314 if ( ! AlibabaCloud . TeaUtil . Common . IsUnset ( response . Headers . Get ( "x-acs-request-id" ) ) )
305315 {
@@ -356,8 +366,18 @@ public async Task ModifyResponseAsync(AlibabaCloud.GatewaySpi.Models.Interceptor
356366 AlibabaCloud . GatewaySpi . Models . InterceptorContext . InterceptorContextResponse response = context . Response ;
357367 if ( AlibabaCloud . TeaUtil . Common . Is4xx ( response . StatusCode ) || AlibabaCloud . TeaUtil . Common . Is5xx ( response . StatusCode ) )
358368 {
359- object _res = AlibabaCloud . TeaUtil . Common . ReadAsJSON ( response . Body ) ;
360- Dictionary < string , object > err = AlibabaCloud . TeaUtil . Common . AssertAsMap ( _res ) ;
369+ Dictionary < string , object > err = new Dictionary < string , object > ( ) { } ;
370+ if ( ! AlibabaCloud . TeaUtil . Common . IsUnset ( response . Headers . Get ( "content-type" ) ) && AlibabaCloud . DarabonbaString . StringUtil . Contains ( response . Headers . Get ( "content-type" ) , "text/xml" ) )
371+ {
372+ string _str = AlibabaCloud . TeaUtil . Common . ReadAsString ( response . Body ) ;
373+ Dictionary < string , object > respMap = AlibabaCloud . TeaXML . Client . ParseXml ( _str , null ) ;
374+ err = AlibabaCloud . TeaUtil . Common . AssertAsMap ( respMap . Get ( "Error" ) ) ;
375+ }
376+ else
377+ {
378+ object _res = AlibabaCloud . TeaUtil . Common . ReadAsJSON ( response . Body ) ;
379+ err = AlibabaCloud . TeaUtil . Common . AssertAsMap ( _res ) ;
380+ }
361381 object requestId = DefaultAny ( err . Get ( "RequestId" ) , err . Get ( "requestId" ) ) ;
362382 if ( ! AlibabaCloud . TeaUtil . Common . IsUnset ( response . Headers . Get ( "x-acs-request-id" ) ) )
363383 {
@@ -552,11 +572,28 @@ public string BuildCanonicalizedResource(Dictionary<string, string> query)
552572
553573 public string BuildCanonicalizedHeaders ( Dictionary < string , string > headers )
554574 {
575+ // lower header key
576+ List < string > headersArray = AlibabaCloud . DarabonbaMap . MapUtil . KeySet ( headers ) ;
577+ Dictionary < string , string > newHeaders = new Dictionary < string , string > ( ) { } ;
578+ string tmp = "" ;
579+
580+ foreach ( var key in headersArray ) {
581+ string lowerKey = AlibabaCloud . DarabonbaString . StringUtil . ToLower ( key ) ;
582+ if ( ! AlibabaCloud . DarabonbaString . StringUtil . Contains ( tmp , lowerKey ) )
583+ {
584+ tmp = "" + tmp + "," + lowerKey ;
585+ newHeaders [ lowerKey ] = AlibabaCloud . DarabonbaString . StringUtil . Trim ( headers . Get ( key ) ) ;
586+ }
587+ else
588+ {
589+ newHeaders [ lowerKey ] = "" + newHeaders . Get ( lowerKey ) + "," + AlibabaCloud . DarabonbaString . StringUtil . Trim ( headers . Get ( key ) ) ;
590+ }
591+ }
555592 string canonicalizedHeaders = "" ;
556593 List < string > sortedHeaders = GetSignedHeaders ( headers ) ;
557594
558595 foreach ( var header in sortedHeaders ) {
559- canonicalizedHeaders = "" + canonicalizedHeaders + header + ":" + AlibabaCloud . DarabonbaString . StringUtil . Trim ( headers . Get ( header ) ) + "\n " ;
596+ canonicalizedHeaders = "" + canonicalizedHeaders + header + ":" + newHeaders . Get ( header ) + "\n " ;
560597 }
561598 return canonicalizedHeaders ;
562599 }
0 commit comments