Stellar1999 commented on PR #15188: URL: https://github.com/apache/dubbo/pull/15188#issuecomment-2692268656
> @Stellar1999 First of all, thank you for responding to this issue so promptly. > > [rfc7231/3.1.1.1. Media Type](https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1) `media-type = type "/" subtype *( OWS ";" OWS parameter )` > > According to the description in the RFC document, the `content-type` may include one or more parameters in addition to the media-type, with `charset` being just one of these parameters. There is no stipulated order for these parameters, so in extreme cases, relying on index positioning could potentially lead to issues. > > Perhaps it is also necessary to define a new method: `String mediaTypeParam(String name);`, to retrieve the value of a specified parameter. > > ``` > String mediaTypeParam(String name) { > paramsStr = contentType.substring(X); > params = paramsStr.split(";") > .filter(str -> str.contain("=")) > .map(str -> str.split("=")); > return params[name]; > } > > var charset = mediaTypeParam("charset"); > var boundary = mediaTypeParam("boundary"); > ``` Thanks for your review. I think my new code does not rely on an index for positioning. (If you mean indexOf, it's only used to get the charset string.) Like you said, maybe we can find a better general method to retrieve more parameters. However, as I see in the Dubbo code, it only relies on the charset. So, I believe we just need a special method to obtain the charset. -- 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]
