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

Use managed HTTP stack #1618

Merged
merged 44 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f9bded4
Use custom HTTPS transport
ethomson Oct 7, 2018
dc22039
Exceptions: refactor native exceptions to include code
ethomson Oct 14, 2018
4381f70
ManagedHttpSmartSubtransport: provide certificate callbacks
ethomson Oct 14, 2018
15d68e5
Managed HTTP transport: support user-agent
ethomson Oct 14, 2018
9d7dd69
Managed HTTP transport: allow custom transport
ethomson Nov 2, 2018
5a64349
smart subtransports: improve safety
ethomson Nov 6, 2018
7be9794
Tests: Don't look for HTTPS in libgit2
ethomson Nov 10, 2018
70b393b
Use the .NET standard HTTP class
ethomson Nov 10, 2018
04094f5
SSL validation: cope with GIT_PASSTHROUGH
ethomson Oct 16, 2019
4a459f1
HTTP: complete only when actually complete
ethomson Oct 16, 2019
814054b
dispose the response
ethomson Jan 7, 2020
efdb363
Fixed build warnings about System.Net.Http version issues
AArnott Jan 30, 2020
f6f3cb6
Throw more precise exceptions when they happen
AArnott Jan 30, 2020
ae1563d
Improve xml doc comments for extensibility point API
AArnott Jan 30, 2020
a46fb80
Increase the size of the very small read buffer
AArnott Jan 30, 2020
e034243
fixup doc comments
ethomson Feb 18, 2020
8d83f06
Update LibGit2Sharp/Core/ManagedHttpSmartSubtransport.cs
bording Apr 3, 2020
0950390
Suppress Expect: 100 Continue header
AArnott Apr 3, 2020
b388b05
Merge pull request #1772 from AArnott/no100Continue
bording Apr 3, 2020
f5abbba
Update SDK version
bording Apr 5, 2020
27a034d
Only use managed https with new net472 target
bording Apr 5, 2020
a0374ba
Don't dispose HttpClientHandler separately
bording Apr 5, 2020
c3ac103
Minor cleanup
bording Apr 5, 2020
807012a
Add net472 test runs
bording Apr 5, 2020
32af8db
Fix LoadFromSpecifiedPath test on net472
bording Apr 5, 2020
9daf4cc
Update to binaries package that doesn't use OpenSSL on linux
bording Apr 5, 2020
80ea092
Fix when Register is called before NativeMethod cctor
bording Apr 7, 2020
35bca83
Fix XML comment
bording Apr 7, 2020
d2db2ac
Cleanup
bording Apr 7, 2020
9ee00e4
Make managed http opt-in on non-Linux OSes
bording Apr 7, 2020
a5ef816
Managed subtransport: support Default Credentials
ethomson May 10, 2020
7ca3791
Move to only netstandard2.0 target
bording May 30, 2020
86be042
Change to an opt-out model for the managed implementation
bording May 30, 2020
0bea3cf
WIP Try using CredentialCache
bording May 30, 2020
2c763f7
Make test pass, can't do this for real though
bording May 30, 2020
9b6043f
Nevermind, can't change handler properties after it's been used
bording May 30, 2020
868eb38
Always use managed https transport
bording Nov 7, 2020
a514c5f
Remove certificate validation check
bording Nov 7, 2020
665eb5f
Add lock to credential cache modifications
bording Nov 7, 2020
2c90f41
Add netcoreapp2.1 target
bording Nov 7, 2020
d4a6cd4
Remove unneeded reference
bording Nov 7, 2020
4a9af01
Use SocketsHttpHandler on .NET Core
bording Nov 7, 2020
2fae75f
Comment out test using deleted repo
bording Nov 7, 2020
fd8e277
Comment out certificate check test
bording Nov 7, 2020
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
1 change: 0 additions & 1 deletion LibGit2Sharp.Tests/GlobalSettingsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public void CanGetMinimumCompiledInFeatures()
BuiltInFeatures features = GlobalSettings.Version.Features;

Assert.True(features.HasFlag(BuiltInFeatures.Threads));
Assert.True(features.HasFlag(BuiltInFeatures.Https));
}

[Fact]
Expand Down
11 changes: 10 additions & 1 deletion LibGit2Sharp/AmbiguousSpecificationException.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using LibGit2Sharp.Core;
using System;
using System.Runtime.Serialization;

Expand All @@ -7,7 +8,7 @@ namespace LibGit2Sharp
/// The exception that is thrown when the provided specification cannot uniquely identify a reference, an object or a path.
/// </summary>
[Serializable]
public class AmbiguousSpecificationException : LibGit2SharpException
public class AmbiguousSpecificationException : NativeException
{
/// <summary>
/// Initializes a new instance of the <see cref="AmbiguousSpecificationException"/> class.
Expand Down Expand Up @@ -50,5 +51,13 @@ public AmbiguousSpecificationException(string message, Exception innerException)
protected AmbiguousSpecificationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }

internal override GitErrorCode ErrorCode
{
get
{
return GitErrorCode.Ambiguous;
}
}
}
}
14 changes: 11 additions & 3 deletions LibGit2Sharp/BareRepositoryException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace LibGit2Sharp
/// working directory is performed against a bare repository.
/// </summary>
[Serializable]
public class BareRepositoryException : LibGit2SharpException
public class BareRepositoryException : NativeException
{
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.BareRepositoryException"/> class.
Expand Down Expand Up @@ -52,8 +52,16 @@ protected BareRepositoryException(SerializationInfo info, StreamingContext conte
: base(info, context)
{ }

internal BareRepositoryException(string message, GitErrorCode code, GitErrorCategory category)
: base(message, code, category)
internal BareRepositoryException(string message, GitErrorCategory category)
: base(message, category)
{ }

internal override GitErrorCode ErrorCode
{
get
{
return GitErrorCode.BareRepo;
}
}
}
}
6 changes: 5 additions & 1 deletion LibGit2Sharp/CertificateX509.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace LibGit2Sharp
/// </summary>
public class CertificateX509 : Certificate
{

/// <summary>
/// For mocking purposes
/// </summary>
Expand All @@ -30,6 +29,11 @@ internal unsafe CertificateX509(git_certificate_x509* cert)
Certificate = new X509Certificate(data);
}

internal CertificateX509(X509Certificate cert)
{
Certificate = cert;
}

internal unsafe IntPtr ToPointers(out IntPtr dataPtr)
{
var certData = Certificate.Export(X509ContentType.Cert);
Expand Down
14 changes: 11 additions & 3 deletions LibGit2Sharp/CheckoutConflictException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace LibGit2Sharp
/// in the working directory.
/// </summary>
[Serializable]
public class CheckoutConflictException : LibGit2SharpException
public class CheckoutConflictException : NativeException
{
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class.
Expand Down Expand Up @@ -53,8 +53,16 @@ protected CheckoutConflictException(SerializationInfo info, StreamingContext con
: base(info, context)
{ }

internal CheckoutConflictException(string message, GitErrorCode code, GitErrorCategory category)
: base(message, code, category)
internal CheckoutConflictException(string message, GitErrorCategory category)
: base(message, category)
{ }

internal override GitErrorCode ErrorCode
{
get
{
return GitErrorCode.Conflict;
}
}
}
}
30 changes: 15 additions & 15 deletions LibGit2Sharp/Core/Ensure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ public static void ArgumentIsExpectedIntPtr(IntPtr argumentValue, IntPtr expecte
}
}

private static readonly Dictionary<GitErrorCode, Func<string, GitErrorCode, GitErrorCategory, LibGit2SharpException>>
private static readonly Dictionary<GitErrorCode, Func<string, GitErrorCategory, LibGit2SharpException>>
GitErrorsToLibGit2SharpExceptions =
new Dictionary<GitErrorCode, Func<string, GitErrorCode, GitErrorCategory, LibGit2SharpException>>
new Dictionary<GitErrorCode, Func<string, GitErrorCategory, LibGit2SharpException>>
{
{ GitErrorCode.User, (m, r, c) => new UserCancelledException(m, r, c) },
{ GitErrorCode.BareRepo, (m, r, c) => new BareRepositoryException(m, r, c) },
{ GitErrorCode.Exists, (m, r, c) => new NameConflictException(m, r, c) },
{ GitErrorCode.InvalidSpecification, (m, r, c) => new InvalidSpecificationException(m, r, c) },
{ GitErrorCode.UnmergedEntries, (m, r, c) => new UnmergedIndexEntriesException(m, r, c) },
{ GitErrorCode.NonFastForward, (m, r, c) => new NonFastForwardException(m, r, c) },
{ GitErrorCode.Conflict, (m, r, c) => new CheckoutConflictException(m, r, c) },
{ GitErrorCode.LockedFile, (m, r, c) => new LockedFileException(m, r, c) },
{ GitErrorCode.NotFound, (m, r, c) => new NotFoundException(m, r, c) },
{ GitErrorCode.Peel, (m, r, c) => new PeelException(m, r, c) },
{ GitErrorCode.User, (m, c) => new UserCancelledException(m, c) },
{ GitErrorCode.BareRepo, (m, c) => new BareRepositoryException(m, c) },
{ GitErrorCode.Exists, (m, c) => new NameConflictException(m, c) },
{ GitErrorCode.InvalidSpecification, (m, c) => new InvalidSpecificationException(m, c) },
{ GitErrorCode.UnmergedEntries, (m, c) => new UnmergedIndexEntriesException(m, c) },
{ GitErrorCode.NonFastForward, (m, c) => new NonFastForwardException(m, c) },
{ GitErrorCode.Conflict, (m, c) => new CheckoutConflictException(m, c) },
{ GitErrorCode.LockedFile, (m, c) => new LockedFileException(m, c) },
{ GitErrorCode.NotFound, (m, c) => new NotFoundException(m, c) },
{ GitErrorCode.Peel, (m, c) => new PeelException(m, c) },
};

private static unsafe void HandleError(int result)
Expand All @@ -145,13 +145,13 @@ private static unsafe void HandleError(int result)
errorMessage = LaxUtf8Marshaler.FromNative(error->Message);
}

Func<string, GitErrorCode, GitErrorCategory, LibGit2SharpException> exceptionBuilder;
Func<string, GitErrorCategory, LibGit2SharpException> exceptionBuilder;
if (!GitErrorsToLibGit2SharpExceptions.TryGetValue((GitErrorCode)result, out exceptionBuilder))
{
exceptionBuilder = (m, r, c) => new LibGit2SharpException(m, r, c);
exceptionBuilder = (m, c) => new LibGit2SharpException(m, c);
}

throw exceptionBuilder(errorMessage, (GitErrorCode)result, errorCategory);
throw exceptionBuilder(errorMessage, errorCategory);
}

/// <summary>
Expand Down
Loading