NodeInfo is read as Mobilizon serves it

Mobilizon sends its NodeInfo as `application/json; profile=http://…#` with the URL unquoted, which .NET cannot parse,
so the document was refused for its content type and the server never described; and it names its software
"Mobilizon" where NodeInfo wants lower case. The media type is now read from the raw header when the parsed one is
missing, and software names are lowercased, so one software is counted under one name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-05 10:45:18 +02:00
1 parent 206506f5e9
commit 7f6837ccb1
4 files changed
+24 -3

No files matched your search

@@ -218,7 +218,7 @@ namespace PrivaPub.Infrastructure.Http
exchange.Refused(StatusReason(response));
return items;
}
var mediaType = response.Content.Headers.ContentType?.MediaType;
var mediaType = MediaType(response.Content.Headers);
if (mediaType == default || !JsonMediaTypes.Contains(mediaType, StringComparer.OrdinalIgnoreCase))
{
exchange.Refused("content-type");
@@ -356,7 +356,7 @@ namespace PrivaPub.Infrastructure.Http
return Refuse(negativeKey, url, $"status {(int)response.StatusCode}", exchange, StatusReason(response),
transient: (int)response.StatusCode is >= 500 or 429 or 408);
var mediaType = response.Content.Headers.ContentType?.MediaType;
var mediaType = MediaType(response.Content.Headers);
if (mediaType == default || !JsonMediaTypes.Contains(mediaType, StringComparer.OrdinalIgnoreCase))
return Refuse(negativeKey, url, $"content type '{mediaType}'", exchange, "content-type");
if (response.Content.Headers.ContentLength > MaxResponseBytes)
@@ -629,6 +629,11 @@ namespace PrivaPub.Infrastructure.Http
static string NegativeKey(Uri target) => "federation-http:refused:" + target.AbsoluteUri;
// the media type, also from a header .NET cannot parse: Mobilizon's NodeInfo leaves its profile URL unquoted
static string MediaType(System.Net.Http.Headers.HttpContentHeaders headers) =>
headers.ContentType?.MediaType
?? (headers.NonValidated.TryGetValues("Content-Type", out var raw) ? raw.ToString().Split(';')[0].Trim() : default);
sealed record Refusal(bool Transient, int Status);
FetchedJson Refuse(string negativeKey, string url, string reason, Exchange exchange, string code, bool transient = false)