merlimat commented on a change in pull request #2888: PIP-25: Token based
authentication
URL: https://github.com/apache/pulsar/pull/2888#discussion_r236793697
##########
File path:
pulsar-common/src/main/java/org/apache/pulsar/client/api/url/DataURLStreamHandler.java
##########
@@ -57,20 +60,23 @@ public void connect() throws IOException {
if (this.uri == null) {
throw new IOException();
}
- Pattern pattern = Pattern.compile(
-
"(?<mimeType>.+?)(;(?<charset>charset=.+?))?(;(?<base64>base64?))?,(?<data>.+)",
Pattern.DOTALL);
+
Matcher matcher =
pattern.matcher(this.uri.getSchemeSpecificPart());
if (matcher.matches()) {
this.contentType = matcher.group("mimeType");
- String charset = matcher.group("charset");
- if (charset == null) {
- charset = "US-ASCII";
+ if (contentType == null) {
+ this.contentType = "application/data";
}
+
+ for (int i =0; i < matcher.groupCount(); i++) {
+ System.out.println("Group: " + matcher.group(i));
+ }
+
if (matcher.group("base64") == null) {
// Support Urlencode but not decode here because already
decoded by URI class.
- this.data = new String(matcher.group("data").getBytes(),
charset);
+ this.data = matcher.group("data").getBytes();
Review comment:
The problem with original code is that it was getting a list of bytes and
converting them into a `String` (which in case of keys is not possible) and
then exposing back to a `ByteArrayInputStream`. I just cut through the String
conversion
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services