簡體   English   中英

在dotNetRdf中為遠程SPARQL連接器應用自定義請求選項

[英]Applying custom request options for a remote SPARQL connector in dotNetRdf

我試圖將自定義標頭添加到SPARQL端點連接器問題的HTTP requset。 連接器可以使用自定義的遠程端點 ,該端點繼承了我可以覆蓋的ApplyCustomRequestOptions方法。 該方法的文檔說

[...]將任何其他自定義請求選項/標頭添加到請求中。

但是,從未調用我的重寫方法(因此,未應用我的自定義選項,因此無法添加標頭)。

以下代碼按預期工作,但從未調用我的ApplyCustomRequestOptions

using System;
using System.Net;
using VDS.RDF.Query;
using VDS.RDF.Storage;

class Program
{
    static void Main(string[] args)
    {
        var endpointUri = new Uri("https://query.wikidata.org/sparql");

        var endpoint = new CustomEndpoint(endpointUri);

        using (var connector = new SparqlConnector(endpoint))
        {
            var result = connector.Query("SELECT * WHERE {?s ?p ?o} LIMIT 1");
        }
    }
}

public class CustomEndpoint : SparqlRemoteEndpoint
{
    public CustomEndpoint(Uri endpointUri) : base(endpointUri) { }

    protected override void ApplyCustomRequestOptions(HttpWebRequest httpRequest)
    {
        // This is never executed.
        base.ApplyCustomRequestOptions(httpRequest);
        // Implementation omitted.
    }
}

這是使用這些方法的正確方法嗎? 如果不是,那是什么?

順便說一句,這是dotNetRdf 1.0.12,.NET 4.6.1。 我嘗試了多個SPARQL端點,多個查詢( SELECTCONSTRUCT )和SparqlConnector.Query多個調用。

這是一個錯誤。 我已找到問題並解決,並提交了PR。 您可以在此處跟蹤問題的狀態: https : //github.com/dotnetrdf/dotnetrdf/issues/103

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM