< Summary

Information
Class: System.Net.Http.HttpContentStream
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\HttpContentStream.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 24
Coverable lines: 24
Total lines: 47
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
Write(...)100%110%
Dispose(...)0%440%
GetConnectionOrThrow()100%110%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\HttpContentStream.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4namespace System.Net.Http
 5{
 6    internal abstract class HttpContentStream : HttpBaseStream
 7    {
 8        protected internal HttpConnection? _connection;
 9
 010        public HttpContentStream(HttpConnection connection)
 011        {
 012            _connection = connection;
 013        }
 14
 15        public override void Write(byte[] buffer, int offset, int count)
 016        {
 017            ValidateBufferArguments(buffer, offset, count);
 018            Write(new ReadOnlySpan<byte>(buffer, offset, count));
 019        }
 20
 21        protected override void Dispose(bool disposing)
 022        {
 023            if (disposing)
 024            {
 025                if (_connection != null)
 026                {
 027                    _connection.Dispose();
 028                    _connection = null;
 029                }
 030            }
 31
 032            base.Dispose(disposing);
 033        }
 34
 35        protected HttpConnection GetConnectionOrThrow()
 036        {
 037            HttpConnection? c = _connection;
 38
 39            // Disposal should only ever happen if the user-code that was handed this instance disposed of
 40            // it, which is misuse, or held onto it and tried to use it later after we've disposed of it,
 41            // which is also misuse.
 042            ObjectDisposedException.ThrowIf(c is null, this);
 43
 044            return c;
 045        }
 46    }
 47}