为 dotNetRdf 中的远程 SPARQL 连接器应用自定义请求选项
Applying custom request options for a remote SPARQL connector in dotNetRdf
我正在尝试向 HTTP 请求添加自定义 headers 一个我可以覆盖的 SPARQL endpoint connector issues. The connector can use a custom remote endpoint, which inherits an ApplyCustomRequestOptions 方法。该方法的文档说
[...] add any additional custom request options/headers to the request.
但是我重写的方法从未被调用(所以我的自定义选项没有应用,所以我无法添加 headers)。
以下代码按预期工作,除了我的 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 端点、多个查询(SELECT
& CONSTRUCT
)和 SparqlConnector.Query
.
的多个调用
这是一个错误。我已经找到问题并修复它并提交了 PR。您可以在此处跟踪问题的状态:https://github.com/dotnetrdf/dotnetrdf/issues/103
我正在尝试向 HTTP 请求添加自定义 headers 一个我可以覆盖的 SPARQL endpoint connector issues. The connector can use a custom remote endpoint, which inherits an ApplyCustomRequestOptions 方法。该方法的文档说
[...] add any additional custom request options/headers to the request.
但是我重写的方法从未被调用(所以我的自定义选项没有应用,所以我无法添加 headers)。
以下代码按预期工作,除了我的 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 端点、多个查询(SELECT
& CONSTRUCT
)和 SparqlConnector.Query
.
这是一个错误。我已经找到问题并修复它并提交了 PR。您可以在此处跟踪问题的状态:https://github.com/dotnetrdf/dotnetrdf/issues/103