Skip to content

Commit

Permalink
Merge pull request #5807 from thc202/exim/fix-body
Browse files Browse the repository at this point in the history
  • Loading branch information
kingthorin authored Oct 10, 2024
2 parents 3071f7c + 9e03961 commit a66fe85
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion addOns/exim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Maintenance changes.

## [0.12.0] - 2024-10-07
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ public static HarRequest createHarRequest(HttpMessage httpMessage) {
text = requestBody.toString();
}
}
HarPostData newPostData = new HarPostData();
newPostData.setMimeType(contentType);
newPostData.setParams(params);
newPostData.setText(text);
harPostData = new HarPostData();
harPostData.setMimeType(contentType);
harPostData.setParams(params);
harPostData.setText(text);
}

HttpMethod method = HttpMethod.valueOf(requestHeader.getMethod().toUpperCase(Locale.ROOT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,27 @@ void reset() throws URISyntaxException {
@Test
void serializedAndDeserializedShouldMatch() throws Exception {
// Given
var requestHeader =
"POST http://example.com/path HTTP/1.1\r\nContent-Type: application/octet-stream\r\n\r\n";
var responseHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/plain;charset=US-ASCII\r\n\r\n";
byte[] requestBody = {0x01, 0x02};
byte[] responseBody = {0x30, 0x31};
HttpMessage httpMessage =
new HttpMessage(
"POST /path HTTP/1.1\r\nContent-Type: application/octet-stream\r\n\r\n",
requestBody,
"HTTP/1.1 200 OK\r\nContent-Type: text/plain;charset=US-ASCII\r\n\r\n",
responseBody);
new HttpMessage(requestHeader, requestBody, responseHeader, responseBody);

HarLog harLog = createHarLog(httpMessage);
// When
List<HttpMessage> deserialized = HarImporter.getHttpMessages(harLog);
// Then
assertThat(deserialized, hasSize(1));
assertThat(deserialized.get(0), equalTo(httpMessage));
var deserializedHttpMessage = deserialized.get(0);
assertThat(
deserializedHttpMessage.getRequestHeader().toString(), is(equalTo(requestHeader)));
assertThat(deserializedHttpMessage.getRequestBody().getBytes(), is(equalTo(requestBody)));
assertThat(
deserializedHttpMessage.getResponseHeader().toString(),
is(equalTo(responseHeader)));
assertThat(deserializedHttpMessage.getResponseBody().getBytes(), is(equalTo(responseBody)));
}

@Test
Expand Down

0 comments on commit a66fe85

Please sign in to comment.