Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit bd93302

Browse files
committed
Merge pull request #2676 from dotnet-bot/from-tfs
Merge changes from TFS
2 parents 4ef8cc9 + e298b31 commit bd93302

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/System.Net.Http/src/System/Net/Http/ByteArrayContent.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public ByteArrayContent(byte[] content)
2323
_content = content;
2424
_offset = 0;
2525
_count = content.Length;
26+
27+
#if NETNative
28+
SetBuffer(_content, _offset, _count);
29+
#endif
2630
}
2731

2832
public ByteArrayContent(byte[] content, int offset, int count)
@@ -43,6 +47,10 @@ public ByteArrayContent(byte[] content, int offset, int count)
4347
_content = content;
4448
_offset = offset;
4549
_count = count;
50+
51+
#if NETNative
52+
SetBuffer(_content, _offset, _count);
53+
#endif
4654
}
4755

4856
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)

src/System.Net.Http/src/System/Net/Http/HttpContent.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ private bool IsBuffered
5252
get { return _bufferedContent != null; }
5353
}
5454

55+
#if NETNative
56+
internal void SetBuffer(byte[] buffer, int offset, int count)
57+
{
58+
_bufferedContent = new MemoryStream(buffer, offset, count, false, true);
59+
}
60+
61+
internal bool TryGetBuffer(out ArraySegment<byte> buffer)
62+
{
63+
if (_bufferedContent == null)
64+
{
65+
return false;
66+
}
67+
68+
return _bufferedContent.TryGetBuffer(out buffer);
69+
}
70+
#endif
71+
5572
protected HttpContent()
5673
{
5774
// Log to get an ID for the current content. This ID is used when the content gets associated to a message.

0 commit comments

Comments
 (0)