Skip to content

Commit edc8a28

Browse files
committed
Document contentLength calculation
1 parent d5740e7 commit edc8a28

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,11 @@ public long contentLength() throws IOException {
913913
return Long.parseLong(
914914
contentLength.toArray(new String[] {})[0]);
915915
}
916+
// super.contentLength() is not relied on since it defaults to -1L, causing wrong telemetry added to the attributes.
916917
if (requestInfo.content instanceof ByteArrayInputStream) {
917918
final ByteArrayInputStream contentStream =
918919
(ByteArrayInputStream) requestInfo.content;
920+
// using available() on a byte-array backed input stream is reliable because array size is defined.
919921
return contentStream.available();
920922
}
921923
return super.contentLength();

0 commit comments

Comments
 (0)