搜索 Ada Lib 以通过 http 打开文件

发布于 2024-10-14 05:09:30 字数 263 浏览 6 评论 0原文

我正在寻找一个库,我可以将其包含在程序中以打开具有给定互联网地址的文件。就像 http://foobar.com/foobar.txt 一样。

喜欢

Ada.Text_IO.Open (File, Ada.Text_IO.In_File, "bla.txt");
but which is not limited on local files.

I'm searching for a Library which I can include in a program to open a file with a given internet address. Just like http://foobar.com/foobar.txt.

Like

Ada.Text_IO.Open (File, Ada.Text_IO.In_File, "bla.txt");

but which is not limited on local files.

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

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

发布评论

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

评论(2

浮生未歇 2024-10-21 05:09:30

好吧,您不可能找到具有确切接口的东西,因为 Text_IO 是一个标准库,第三方无法以这种方式轻松扩展。

如果您的平台的底层文件系统支持 HTTP,那么它就会像您想要的那样工作。但我不知道有哪个平台可以这样工作。

您可能想要的通用解决方案是 AWS(Ada Web 服务器)。如果愿意的话,人们可以使用它来实现一个成熟的 Web 服务器,但它也包含 HTTP 客户端设施。 HTTP 客户端将是您想要的(请参阅 AWS.Client)。与仅进行一次标准 API 调用相比,您需要做更多的工作,但可能不需要太多工作。

下面是一个摘自 Rosetta 代码 的示例:

with Ada.Text_IO; 
use Ada.Text_IO; 
with AWS.Client;
with AWS.Response; 
procedure HTTP_Request is
begin
   Put_Line (AWS.Response.Message_Body (AWS.Client.Get (URL => "http://www.rosettacode.org")));
end HTTP_Request;

Well, you aren't liable to find something with that exact interface, as Text_IO is a standard library and can't easily be extended by third parties in that way.

If your platform's underlying filesystem were to support HTTP, then it would work just like you want. I don't know of any platform that works that way however.

What you probably want as a general solution is AWS (Ada Web Server). A person could use that to implement a full-blown web server if they want, but it also contains HTTP client facilities. The HTTP client would be what you want (see AWS.Client). It would be a bit more work on your part than just making one standard API call, but probably no too much work.

Here's an example, cribbed from Rosetta Code:

with Ada.Text_IO; 
use Ada.Text_IO; 
with AWS.Client;
with AWS.Response; 
procedure HTTP_Request is
begin
   Put_Line (AWS.Response.Message_Body (AWS.Client.Get (URL => "http://www.rosettacode.org")));
end HTTP_Request;
岁月染过的梦 2024-10-21 05:09:30

在使用和实现了多个 HTTP 客户端之后,我建议您使用已建立的专用客户端。 HTTP 标准有许多错综复杂的问题,无法通过简单的实现来处理 https://www.rfc -editor.org/rfc/rfc2616

考虑将 Ada Bindings 用于像 libCURL 这样的成熟库; http://curl.haxx.se/libcurl/ada95/

Having used and implemented several HTTP clients, I would advise you to use an established and dedicated client. There are many intricacies to the HTTP standard that are not handled by naive implementations https://www.rfc-editor.org/rfc/rfc2616.

Consider using the Ada Bindings for a mature library like libCURL; http://curl.haxx.se/libcurl/ada95/

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