Skip to content

Fetch failed with "Received unexpected content-type"  #1094

@suwatch

Description

@suwatch

When fetching from a certain implementation of a git repo, we got into the issue. This works with git.exe fetch.

LibGit2Sharp.LibGit2SharpException: Received unexpected content-type
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteSafeHandle remote, Signature signature, String logMessage)
   at LibGit2Sharp.Network.DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signature signature, String logMessage)
   at LibGit2Sharp.Network.Fetch(Remote remote, FetchOptions options, Signature signature, String logMessage)
   at LibGitTest.Program.Main(String[] args) in c:\temp\OneDriveTest\LibGitTest\Program.cs:line 40

I compare interaction differences below.

A normal git fetch would interact as below.

> GET /info/refs?service=git-upload-pack HTTP/1.1
< HTTP/1.1 200 OK
< Content-Length: 290
< Content-Type: application/x-git-upload-pack-advertisement

> POST /git-upload-pack HTTP/1.1
> Content-Length: 150
< HTTP/1.1 200 OK
< Content-Type: application/x-git-upload-pack-result

However this specific git server return content-type as text/plain and LibGit2Sharp failed.

> GET /d0071380/info/refs?service=git-upload-pack HTTP/1.1
< HTTP/1.1 200 OK
< Content-Length: 59
< Content-Type: text/plain; charset=UTF-8

> GET /d0071380/HEAD HTTP/1.1
< HTTP/1.1 200 OK
< Content-Length: 23
< Content-Type: text/plain; charset=UTF-8

> GET /d0071380/objects/e5/5bb491ceac5433b1189d3554f7e6ffe7d523e7 HTTP/1.1
< HTTP/1.1 200 OK
< Content-Length: 121
< Content-Type: text/plain; charset=UTF-8

> GET /d0071380/objects/8f/bbafc82747ec6ad17edf4af97cb37033760812 HTTP/1.1
< HTTP/1.1 200 OK
< Content-Length: 55
< Content-Type: text/plain; charset=UTF-8

> GET /d0071380/objects/a9/21e7e8c7a688717f21bdc73eafe19c1d77d3a5 HTTP/1.1
< HTTP/1.1 200 OK
< Content-Length: 82
< Content-Type: text/plain; charset=UTF-8

Given the client git.exe works, I believe it is an also supported protocol but Libgit2Sharp did not support it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions