icodening commented on code in PR #13387:
URL: https://github.com/apache/dubbo/pull/13387#discussion_r1408849327
##########
dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/AbstractServerHttpChannelObserver.java:
##########
@@ -77,7 +83,8 @@ public void onNext(Object data) {
}
HttpOutputMessage outputMessage = encodeHttpOutputMessage(data);
preOutputMessage(outputMessage);
- this.httpMessageCodec.encode(outputMessage.getBody(), data);
+ this.responseEncoder.encode(outputMessage.getBody(), data);
+ // TODO: write时写入的序列化信息是客户端支持的吗?
Review Comment:
plz use english
##########
dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/HttpMessageCodec.java:
##########
@@ -48,8 +50,22 @@ default Object[] decode(InputStream inputStream, Class<?>[]
targetTypes) throws
MediaType contentType();
+ default MediaType responseContentType() {
Review Comment:
Why add `responseContentType` method?
##########
dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/HttpMessageCodecFactory.java:
##########
@@ -27,12 +29,19 @@
@SPI(scope = ExtensionScope.FRAMEWORK)
public interface HttpMessageCodecFactory {
- HttpMessageCodec createCodec(URL url, FrameworkModel frameworkModel);
+ HttpMessageCodec createCodec(URL url, FrameworkModel frameworkModel,
HttpHeaders headers);
MediaType contentType();
- default boolean support(String contentType) {
+ default boolean supportDecode(HttpHeaders headers) {
+ String contentType =
headers.getFirst(HttpHeaderNames.CONTENT_TYPE.getName());
MediaType mediaType = this.contentType();
- return mediaType.getName().startsWith(contentType);
+ return contentType.startsWith(mediaType.getName());
+ }
+
+ default boolean supportEncode(HttpHeaders headers) {
+ String acceptEncoding =
headers.getFirst(HttpHeaderNames.ACCEPT.getName());
+ return acceptEncoding != null
+ && acceptEncoding.contains(this.contentType().getName());
Review Comment:
Maybe it shouldn't be removed `boolean support(String contentType)`, you can
call `support(String)` with header value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]