Skip to content

Commit

Permalink
Merge pull request #6066 from psiinon/exim/site-export-fix
Browse files Browse the repository at this point in the history
Exim: Site export fix
  • Loading branch information
thc202 authored Jan 6, 2025
2 parents 0389039 + 650862f commit d59041e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ private static void outputNode(
if (HttpRequestHeader.POST.equals(href.getMethod())) {
try {
HttpMessage msg = href.getHttpMessage();
if (!msg.getRequestHeader()
.getHeader(HttpHeader.CONTENT_TYPE)
.startsWith(HttpHeader.FORM_MULTIPART_CONTENT_TYPE)) {
String contentType = msg.getRequestHeader().getHeader(HttpHeader.CONTENT_TYPE);
if (contentType == null
|| !contentType.startsWith(HttpHeader.FORM_MULTIPART_CONTENT_TYPE)) {
List<NameValuePair> params =
Model.getSingleton().getSession().getParameters(msg, Type.form);
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,36 @@ void shouldOutputNodeWithData() throws Exception {
assertThat(result.getCount(), is(2));
}

@Test
void shouldOutputNodeWithDataButNoContentType() throws Exception {
// Given
String expectedYaml =
"- node: Sites\n"
+ " children: \n"
+ " - node: https://www.example.com\n"
+ " url: https://www.example.com?aa=bb&cc=dd\n"
+ " method: POST\n"
+ " responseLength: 61\n"
+ " statusCode: 200\n"
+ " data: eee=&ggg=\n";
HttpMessage msg =
new HttpMessage(
"POST https://www.example.com?aa=bb&cc=dd HTTP/1.1\r\n",
"eee=fff&ggg=hhh".getBytes(),
"HTTP/1.1 200 OK\r\n" + "content-length: 20",
"12345678901234567890".getBytes());
siteMap.addPath(getHref(msg));
StringWriter sw = new StringWriter();
ExporterResult result = new ExporterResult();

// When
SitesTreeHandler.exportSitesTree(sw, siteMap, result);

// Then
assertThat(sw.toString(), is(expectedYaml));
assertThat(result.getCount(), is(2));
}

@Test
void shouldOutputNodes() throws Exception {
// Given
Expand All @@ -181,13 +211,22 @@ void shouldOutputNodes() throws Exception {
+ " url: https://www.example.com\n"
+ " method: GET\n"
+ " children: \n"
+ " - node: POST:/()\n"
+ " - node: POST:/()(aaa)\n"
+ " url: https://www.example.com/\n"
+ " method: POST\n"
+ " responseLength: 61\n"
+ " statusCode: 200\n"
+ " data: aaa=\n"
+ " - node: PUT:aaa\n"
+ " url: https://www.example.com/aaa\n"
+ " method: PUT\n";
siteMap.addPath(getHref("https://www.example.com/", "POST"));
HttpMessage msg =
new HttpMessage(
"POST https://www.example.com/ HTTP/1.1\r\n",
"aaa=bbb".getBytes(),
"HTTP/1.1 200 OK\r\n" + "content-length: 20",
"12345678901234567890".getBytes());
siteMap.addPath(getHref(msg));
siteMap.addPath(getHref("https://www.example.com/aaa", "PUT"));

StringWriter sw = new StringWriter();
Expand Down

0 comments on commit d59041e

Please sign in to comment.