@@ -73,6 +73,10 @@ public void modifyRequest(com.aliyun.gateway.spi.models.InterceptorContext conte
73
73
} else if (com .aliyun .darabonbastring .Client .equals (request .reqBodyType , "binary" )) {
74
74
// content-type: application/octet-stream
75
75
bodyBytes = com .aliyun .teautil .Common .assertAsBytes (request .body );
76
+ } else if (com .aliyun .darabonbastring .Client .equals (request .reqBodyType , "protobuf" )) {
77
+ byte [] pbBytes = com .aliyun .gateway .sls .util .Client .serializeToPbBytes (request .body );
78
+ request .stream = Tea .toReadable (pbBytes );
79
+ request .headers .put ("content-type" , "application/x-protobuf" );
76
80
}
77
81
78
82
}
@@ -83,7 +87,7 @@ public void modifyRequest(com.aliyun.gateway.spi.models.InterceptorContext conte
83
87
// for php bug, Argument #1 ($value) could not be passed by reference
84
88
if (!com .aliyun .teautil .Common .isUnset (rawSizeRef )) {
85
89
bodyRawSize = rawSizeRef ;
86
- } else if (!com .aliyun .teautil .Common .isUnset (request . body )) {
90
+ } else if (!com .aliyun .teautil .Common .isUnset (bodyBytes )) {
87
91
bodyRawSize = "" + com .aliyun .gateway .sls .util .Client .bytesLength (bodyBytes ) + "" ;
88
92
}
89
93
@@ -199,17 +203,19 @@ public String makeContentHash(byte[] content, String signatureVersion) throws Ex
199
203
public void modifyResponse (com .aliyun .gateway .spi .models .InterceptorContext context , com .aliyun .gateway .spi .models .AttributeMap attributeMap ) throws Exception {
200
204
com .aliyun .gateway .spi .models .InterceptorContext .InterceptorContextRequest request = context .request ;
201
205
com .aliyun .gateway .spi .models .InterceptorContext .InterceptorContextResponse response = context .response ;
202
- if (com .aliyun .teautil .Common .is4xx (response .statusCode ) || com .aliyun .teautil .Common .is5xx (response .statusCode )) {
206
+ Number statusCode = response .statusCode ;
207
+ String requestId = response .headers .get ("x-log-requestid" );
208
+ if (com .aliyun .teautil .Common .is4xx (statusCode ) || com .aliyun .teautil .Common .is5xx (statusCode )) {
203
209
Object error = com .aliyun .teautil .Common .readAsJSON (response .body );
204
210
java .util .Map <String , Object > resMap = com .aliyun .teautil .Common .assertAsMap (error );
205
211
throw new TeaException (TeaConverter .buildMap (
206
212
new TeaPair ("code" , resMap .get ("errorCode" )),
207
213
new TeaPair ("message" , resMap .get ("errorMessage" )),
208
214
new TeaPair ("accessDeniedDetail" , resMap .get ("accessDeniedDetail" )),
209
215
new TeaPair ("data" , TeaConverter .buildMap (
210
- new TeaPair ("httpCode" , response . statusCode ),
211
- new TeaPair ("requestId" , response . headers . get ( "x-log-requestid" ) ),
212
- new TeaPair ("statusCode" , response . statusCode )
216
+ new TeaPair ("httpCode" , statusCode ),
217
+ new TeaPair ("requestId" , requestId ),
218
+ new TeaPair ("statusCode" , statusCode )
213
219
))
214
220
));
215
221
}
@@ -235,6 +241,9 @@ public void modifyResponse(com.aliyun.gateway.spi.models.InterceptorContext cont
235
241
response .deserializedBody = obj ;
236
242
} else if (com .aliyun .teautil .Common .equalString (request .bodyType , "array" )) {
237
243
response .deserializedBody = com .aliyun .teautil .Common .readAsJSON (uncompressedData );
244
+ } else if (com .aliyun .teautil .Common .equalString (request .bodyType , "protobuf" )) {
245
+ byte [] pbBytes = com .aliyun .teautil .Common .readAsBytes (uncompressedData );
246
+ response .deserializedBody = com .aliyun .gateway .sls .util .Client .deserializeFromPbBytes (pbBytes , statusCode , response .headers );
238
247
} else {
239
248
response .deserializedBody = com .aliyun .teautil .Common .readAsString (uncompressedData );
240
249
}
0 commit comments