Skip to content

Commit

Permalink
Merge pull request #5816 from thc202/exim/har-entry-times
Browse files Browse the repository at this point in the history
exim: import HAR entry timings
  • Loading branch information
psiinon authored Oct 16, 2024
2 parents 0ac0036 + 1a9214e commit 14bcf85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addOns/exim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Maintenance changes.

### Fixed
- Import HAR entry sent and elapsed time.

## [0.12.0] - 2024-10-07
### Changed
- Improved HTTP 1.1 traffic detection in PCAP files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
import de.sstoehr.harreader.model.HarHeader;
import de.sstoehr.harreader.model.HarLog;
import de.sstoehr.harreader.model.HarResponse;
import de.sstoehr.harreader.model.HarTiming;
import java.io.File;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -216,6 +219,10 @@ private static HttpMessage getHttpMessage(HarEntry harEntry)
headerEx.getMessage());
return null;
}
result.setTimeSentMillis(
Optional.ofNullable(harEntry.getStartedDateTime()).map(Date::getTime).orElse(0L));
result.setTimeElapsedMillis(
Optional.ofNullable(harEntry.getTimings()).map(HarTiming::getReceive).orElse(0));
setHttpResponse(harEntry.getResponse(), result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ void serializedAndDeserializedShouldMatch() throws Exception {
byte[] responseBody = {0x30, 0x31};
HttpMessage httpMessage =
new HttpMessage(requestHeader, requestBody, responseHeader, responseBody);
long timeSentMillis = 1234L;
httpMessage.setTimeSentMillis(timeSentMillis);
int timeElapsedMillis = 42;
httpMessage.setTimeElapsedMillis(timeElapsedMillis);

HarLog harLog = createHarLog(httpMessage);
// When
Expand All @@ -173,6 +177,8 @@ void serializedAndDeserializedShouldMatch() throws Exception {
deserializedHttpMessage.getResponseHeader().toString(),
is(equalTo(responseHeader)));
assertThat(deserializedHttpMessage.getResponseBody().getBytes(), is(equalTo(responseBody)));
assertThat(deserializedHttpMessage.getTimeSentMillis(), is(equalTo(timeSentMillis)));
assertThat(deserializedHttpMessage.getTimeElapsedMillis(), is(equalTo(timeElapsedMillis)));
}

@Test
Expand Down

0 comments on commit 14bcf85

Please sign in to comment.