-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add Profile field support to HTTP ContentType (resolves #127) #174
base: main
Are you sure you want to change the base?
Conversation
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.
@puzzler995 thank you so much for the contribution! I left a few requests, but I can make the changes myself if you prefer.
/// <param name="MediaType">A MIME type for the header</param> | ||
/// <param name="Profile">A profile to append to the MIME type, leave empty for none</param> | ||
public record struct ContentType(string MediaType, string Profile); |
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.
can we make Profile optional, with a default value of ""
?
@@ -100,6 +103,17 @@ private async Task<ASType> Get(Uri uri, Type targetType, int? maxRecursion, Canc | |||
return obj; | |||
} | |||
|
|||
private static bool IsContentTypeMatch(MediaTypeHeaderValue actual, ActivityPubOptions.ContentType expected) { |
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.
could we move this logic to the equality method in ContentType
? https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/records#equality-members
@@ -33,7 +33,10 @@ public ActivityPubClient(ActivityPubOptions apOptions, IJsonLdSerializer jsonLdS | |||
// https://stackoverflow.com/questions/47176104/c-sharp-add-accept-header-to-httpclient | |||
foreach (var mimeType in apOptions.RequestContentTypes) | |||
{ | |||
var mediaType = new MediaTypeWithQualityHeaderValue(mimeType); | |||
var mediaType = new MediaTypeWithQualityHeaderValue(mimeType.MediaType); |
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.
could we move this logic to an implicit cast in ContentType
?
Modified ActivityPubOptions and ActivityPubClient to instead have a ContentType record struct, so it can handle both MediaType and Profile.
Feel free to let me know if there's anything I need to change. I've tested it as much as I can, but if you know of any softwares that actually follow the spec on this that I can test against, I will for sure.