-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #2225 update request and response transformer to remove underto…
…w objects in the yaml-rule-plugin input (#2226)
- Loading branch information
Showing
3 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
http-entity/src/main/java/com/networknt/http/UndertowConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.networknt.http; | ||
|
||
import io.undertow.util.HeaderMap; | ||
|
||
import java.util.Deque; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class UndertowConverter { | ||
public static Map<String, String> convertHeadersToMap(HeaderMap headerMap) { | ||
Map<String, String> headers = new HashMap<>(); | ||
headerMap.forEach(header -> { | ||
headers.put(header.getHeaderName().toString(), header.getFirst()); | ||
}); | ||
return headers; | ||
} | ||
|
||
public static Map<String, String> convertParametersToMap(Map<String, Deque<String>> parameters) { | ||
Map<String, String> paramMap = new HashMap<>(); | ||
// Iterate over the parameter names and values | ||
for (Map.Entry<String, Deque<String>> entry : parameters.entrySet()) { | ||
String paramName = entry.getKey(); | ||
Deque<String> paramValues = entry.getValue(); | ||
if (!paramValues.isEmpty()) { | ||
// For simplicity, only consider the first value if there are multiple values | ||
paramMap.put(paramName, paramValues.getFirst()); | ||
} | ||
} | ||
return paramMap; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters