Skip to content

Commit

Permalink
set source and target to 1.8 to fix workflow failure, adapted parser
Browse files Browse the repository at this point in the history
  • Loading branch information
miladhub committed Dec 25, 2023
1 parent b3827d6 commit e195915
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions samples/client/petstore/java/resteasy-echo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>11</source>
<target>11</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ public class EchoServerResponseParser {
public String path; // e.g. /query/style_form/explode_true/object?id=12345
public String protocol; // e.g. HTTP/1.1
public java.util.HashMap<String, String> headers = new java.util.HashMap<>();
public String body; // e.g. <html><head></head><body>Hello World!</body></html>

public EchoServerResponseParser(String response) {
if (response == null) {
throw new RuntimeException("Echo server response cannot be null");
}

Iterable<String> lines = response.lines()::iterator;
String[] lines = response.split("\n");
boolean firstLine = true;
boolean bodyStart = false;
StringBuilder bodyBuilder = new StringBuilder();

for (String line : lines) {
if (firstLine) {
Expand All @@ -43,23 +40,12 @@ public EchoServerResponseParser(String response) {
continue;
}

if (bodyStart) {
bodyBuilder.append(line);
bodyBuilder.append("\n");
}

if (line.isEmpty()) {
bodyStart = true;
continue;
}

// store the header key-value pair in headers
String[] keyValue = line.split(": ");
if (keyValue.length == 2) { // skip blank line, non key-value pair
this.headers.put(keyValue[0], keyValue[1]);
}
}

body = bodyBuilder.toString();
}
}

0 comments on commit e195915

Please sign in to comment.