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

Add Profile field support to HTTP ContentType (resolves #127) #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

puzzler995
Copy link

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.

Copy link
Owner

@warriordog warriordog left a 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);
Copy link
Owner

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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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);
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants