Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/578 allow chunked read stream write operations #579

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.412
- name: Build
run: dotnet build -c Release
- name: Test
run: dotnet test -c Release --no-build
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Build
run: dotnet build -c Release
- name: Test
run: dotnet test -c Release --no-build
15 changes: 8 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.412
dotnet-version: 6.0.x
- name: Install SignClient tool
run: dotnet tool install --tool-path . SignClient
- name: Install NBGV tool
run: dotnet tool install --tool-path . nbgv
- name: Set Version
run: ./nbgv cloud
- name: Create Packages
- name: Create Packages
run: dotnet pack -c Release -o packages
- name: Sign Packages
run: |
Expand All @@ -35,16 +37,15 @@ jobs:
DNF_CODESIGN_USER: ${{secrets.DNF_CODESIGN_USER}}
DNF_CODESIGN_SECRET: ${{secrets.DNF_CODESIGN_SECRET}}
- name: Push packages to NuGet.org
run: |
dotnet nuget push ./packages/Docker.DotNet.*.nupkg --skip-duplicate -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json
run: dotnet nuget push ./packages/Docker.DotNet.*.nupkg --skip-duplicate -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json
- name: Create Release
uses: actions/github-script@v5
with:
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: context.ref,
tag_name: context.ref,
name: context.ref,
draft: false,
prerelease: false,
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ The `CertFile` in the example above should be a .pfx file (PKCS12 format), if yo
//
// You can do this globally for all certificates:
// (Note: This is not available on netstandard1.6)
ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;

// Or you can do this on a credential by credential basis:
Expand Down
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<IsPackable>true</IsPackable>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<PackageIconUrl>https://camo.githubusercontent.com/fa6d5c12609ed8a3ba1163b96f9e9979b8f59b0d/687474703a2f2f7765732e696f2f566663732f636f6e74656e74</PackageIconUrl>
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
<PackageTags>Docker Container C# .NET</PackageTags>
Expand Down Expand Up @@ -29,8 +29,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.108">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 0 additions & 4 deletions src/Docker.DotNet.BasicAuth/BasicAuthCredentials.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Net.Http;
#if !NETSTANDARD1_6
using System.Security;
#endif

namespace Docker.DotNet.BasicAuth
{
Expand All @@ -17,12 +15,10 @@ public override HttpMessageHandler GetHandler(HttpMessageHandler innerHandler)
return new BasicAuthHandler(_username, _password, innerHandler);
}

#if !NETSTANDARD1_6
public BasicAuthCredentials(SecureString username, SecureString password, bool isTls = false)
: this(new MaybeSecureString(username), new MaybeSecureString(password), isTls)
{
}
#endif

public BasicAuthCredentials(string username, string password, bool isTls = false)
: this(new MaybeSecureString(username), new MaybeSecureString(password), isTls)
Expand Down
33 changes: 0 additions & 33 deletions src/Docker.DotNet.BasicAuth/MaybeSecureString.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
#if !NETSTANDARD1_6
using System.Security;
using System.Runtime.InteropServices;
#endif

namespace Docker.DotNet.BasicAuth
{
internal class MaybeSecureString : IDisposable
{
#if !NETSTANDARD1_6

public SecureString Value { get; }

public MaybeSecureString(string str)
Expand Down Expand Up @@ -66,34 +62,5 @@ public override string ToString()
Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
}
}

#else

public string Value { get; }

public MaybeSecureString(string str)
{
if (string.IsNullOrEmpty(str))
{
throw new ArgumentNullException(nameof(str));
}

Value = str;
}

public void Dispose()
{
}

public MaybeSecureString Copy()
{
return this;
}

public override string ToString()
{
return Value;
}
#endif
}
}
8 changes: 2 additions & 6 deletions src/Docker.DotNet.X509/CertificateCredentials.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#if !NETSTANDARD1_6
using System.Net;
#endif

using System.Net;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Net.Http.Client;
Expand Down Expand Up @@ -29,12 +26,11 @@ public override HttpMessageHandler GetHandler(HttpMessageHandler innerHandler)
};

handler.ServerCertificateValidationCallback = this.ServerCertificateValidationCallback;
#if !NETSTANDARD1_6

if (handler.ServerCertificateValidationCallback == null)
{
handler.ServerCertificateValidationCallback = ServicePointManager.ServerCertificateValidationCallback;
}
#endif

return handler;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Docker.DotNet.X509/RSAUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

#if !NETSTANDARD1_6
using System.Security;
#endif

namespace Docker.DotNet.X509
{
Expand All @@ -19,7 +16,6 @@ public static X509Certificate2 GetCertFromPFX(string pfxFilePath, string passwor
return new X509Certificate2(pfxFilePath, password);
}

#if !NETSTANDARD1_6
public static X509Certificate2 GetCertFromPFXSecure(string pfxFilePath, SecureString password)
{
return new X509Certificate2(pfxFilePath, password);
Expand All @@ -31,7 +27,6 @@ public static X509Certificate2 GetCertFromPEMFiles(string certFilePath, string k
cert.PrivateKey = RSAUtil.ReadFromPemFile(keyFilePath);
return cert;
}
#endif

private static RSACryptoServiceProvider ReadFromPemFile(string pemFilePath)
{
Expand Down
1 change: 0 additions & 1 deletion src/Docker.DotNet/DockerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ await stream.ConnectAsync(timeout, cancellationToken)
return dockerStream;
});

break;

case "tcp":
Expand Down
14 changes: 8 additions & 6 deletions src/Docker.DotNet/Microsoft.Net.Http.Client/ChunkedReadStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public override bool CanWrite
get { return false; }
}

public override bool CanCloseWrite
{
get { return _inner.CanCloseWrite; }
}

public override long Length
{
get { throw new NotSupportedException(); }
Expand Down Expand Up @@ -154,12 +159,12 @@ private void ThrowIfDisposed()

public override void Write(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
_inner.Write(buffer, offset, count);
}

public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
throw new NotSupportedException();
return _inner.WriteAsync(buffer, offset, count, cancellationToken);
}

public override long Seek(long offset, SeekOrigin origin)
Expand All @@ -174,12 +179,9 @@ public override void SetLength(long value)

public override void Flush()
{
throw new NotSupportedException();
_inner.Flush();
}

public override bool CanCloseWrite
=> _inner.CanCloseWrite;

public override void CloseWrite()
{
_inner.CloseWrite();
Expand Down
9 changes: 0 additions & 9 deletions src/Docker.DotNet/Microsoft.Net.Http.Client/ManagedHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,7 @@ private static async Task<Socket> TCPSocketOpenerAsync(string host, int port, Ca
var s = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
try
{
#if (NETSTANDARD1_3 || NETSTANDARD1_6 || NETSTANDARD2_0)
await s.ConnectAsync(address, port).ConfigureAwait(false);
#else
await Task.Factory.FromAsync(
s.BeginConnect,
s.EndConnect,
new IPEndPoint(address, port),
null
).ConfigureAwait(false);
#endif
connectedSocket = s;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE-MIT.txt file for more information.

#if (NETSTANDARD1_6 || NETSTANDARD2_0)

using System;
using System.Diagnostics;
using System.Text;
Expand Down Expand Up @@ -95,5 +93,3 @@ public override SocketAddress Serialize()
public override string ToString() => _path;
}
}

#endif
3 changes: 0 additions & 3 deletions src/Docker.DotNet/QueryStringParameterAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Linq;
#if (NETSTANDARD1_3 || NETSTANDARD1_6 || NETSTANDARD2_0)
using System.Reflection;
#endif

namespace Docker.DotNet
{
Expand Down
4 changes: 2 additions & 2 deletions test/Docker.DotNet.Tests/Docker.DotNet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"/>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="5.0.0" />
Expand Down
Loading