[backend/federation] Reuse XmlSerializer in WebFingerService
This commit is contained in:
parent
28f89f8a18
commit
192f3f0312
1 changed files with 4 additions and 3 deletions
|
@ -38,6 +38,8 @@ public class WebFingerService(
|
|||
private static XmlReaderSettings _xmlReaderSettings =
|
||||
new() { DtdProcessing = DtdProcessing.Ignore, XmlResolver = null };
|
||||
|
||||
private static readonly XmlSerializer XmlSerializer = new(typeof(WebFingerResponse));
|
||||
|
||||
public async Task<WebFingerResponse?> ResolveAsync(string query)
|
||||
{
|
||||
(query, var proto, var domain) = ParseQuery(query);
|
||||
|
@ -65,9 +67,8 @@ public class WebFingerService(
|
|||
_xmlReaderSettings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, XmlResolver = null };
|
||||
|
||||
var reader = XmlReader.Create(await res.Content.ReadAsStreamAsync(cts.Token), _xmlReaderSettings);
|
||||
var deserializer = new XmlSerializer(typeof(WebFingerResponse));
|
||||
|
||||
return deserializer.Deserialize(reader) as WebFingerResponse ??
|
||||
return XmlSerializer.Deserialize(reader) as WebFingerResponse ??
|
||||
throw new Exception("Failed to deserialize xml payload");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue