从 ac# Web 请求的标头中删除换行符

发布于 2024-10-07 01:19:24 字数 952 浏览 4 评论 0原文

我需要从 http web 请求中删除最后一个换行符,以便与 json-rpc 服务进行通信。 .net 生成的请求如下所示。

POST http://localhost.:8332/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)
Authorization: Basic dGlwa2c6dGlwa2c=
Host: localhost.:8332
Content-Length: 42
Expect: 100-continue
Connection: Keep-Alive

{"id":1,"method":"getinfo","params":[]}

我需要的是这样的(请注意最后一个标头值和 json 内容的开头之后缺少的换行符):

POST http://localhost.:8332/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)
Authorization: Basic dGlwa2c6dGlwa2c=
Host: localhost.:8332
Content-Length: 42
Expect: 100-continue
Connection: Keep-Alive
{"id":1,"method":"getinfo","params":[]}

我找不到任何可以操纵实际发送到服务的标头的内容。

请参阅http://www.bitcoin.org/smf/index.php?topic= 2170.0 了解有关该问题的更多背景信息...

I need to remove the last line feed from a http webrequest in order to communicate with an json-rpc service.
The request which .net generates looks like this.

POST http://localhost.:8332/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)
Authorization: Basic dGlwa2c6dGlwa2c=
Host: localhost.:8332
Content-Length: 42
Expect: 100-continue
Connection: Keep-Alive

{"id":1,"method":"getinfo","params":[]}

What I would need would be this (notice the missing line feed after last header value and the begin of the json content):

POST http://localhost.:8332/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)
Authorization: Basic dGlwa2c6dGlwa2c=
Host: localhost.:8332
Content-Length: 42
Expect: 100-continue
Connection: Keep-Alive
{"id":1,"method":"getinfo","params":[]}

I can't find anything where I could manipulate the header which is actually sent to service.

See http://www.bitcoin.org/smf/index.php?topic=2170.0 for more background on the problem...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮云落日 2024-10-14 01:19:24

终于解决了我的(核心)问题。我与 rpc 服务通信的问题是我没有设置内容类型。该服务需要“application/json-rpc”内容类型才能正常工作。

finally resolved my (core) issue. the problem with my communication with the rpc service, was that I had not set content-type. The service was requiring a content-type of "application/json-rpc" to work properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文