-
Notifications
You must be signed in to change notification settings - Fork 396
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
Make transport::Service
Debug
and add some HTTP constants from libgit2.
#1069
Conversation
…'s http transport implementation.
Can you say more about why this change would be added? What would it be used for? Similar to my comment in #1066, adding a public dependency has a pretty high bar. Also, adding a new dependency also has a similar bar to reach of clearly justifying why the cost of adding it for all users is worth it. |
This would be useful for users implementing their own git transport using one of rust's http(s) libraries (i.e. ureq, reqwest, etc). The headers and methods used by git protocol over http(s) are the same regardless of the client/implementation/etc, so making those available to anyone writing their own transport saves them from having to implement essentially identical functions. I think it's super fair to not want to add more public dependencies (due to the cost downstream to match the version and have an extra crate to compile). The solutions here are either to gate anything using/exposing the |
/// The value of the HTTP "Accept" header that is used by libgit2's implementation for http(s) transport. | ||
pub const fn http_accept_header(self) -> &'static str { | ||
match self { | ||
Service::UploadPackLs => "application/x-git-upload-pack-advertisement", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a public interface exposed by libgit2? If not I tend not to add this. We don't really want to get into troubles that there is no stability guarantee in libgit2 while git2-rs exposes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire Service
type is native to git2-rs
-- libgit2 doesn't have anything really matching it. The closest thing is https://github.com/libgit2/libgit2/blob/main/src/libgit2/transports/http.c but that is not publicly exposed. I can definitely understand not merging this because of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate your understanding. Yeah we need to weight on that.
Anyway, as GitHub keeps diff in a pull request indefinitely, this can be used as a reference when people need such a glue code, which is great!
Per discussion, I am going to close this and thank you again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course! You're welcome!
This PR adds a dependency on the
http
crate for thehttp::Method
type, and adds some HTTP related constants defined inlibgit2
at https://github.com/libgit2/libgit2/blob/2ecc8586f7eec4063b5da1563d0a33f9e9f9fcf7/src/libgit2/transports/http.c#L68-L95.