C ++, Ifstream opens a local file, but not a file on an HTTP server

I use ifstream to open the file and then read it. My program works fine when I can specify a local file on my system. e.g. /root/Desktop/abc.xxx works fine

But once the location is on the http server, the file cannot open. for example, http://192.168.0.10/abc.xxx does not open.

Is there an alternative for ifstream when using a url?

thank.

+3
source share
4 answers

There are no utilities in the C ++ standard library for accessing data via the http protocol.

Third-party libraries exist : Libwww libcurl

- , http . , http. - http://okmij.org/ftp/HTTP-VFS.html

+5

ifstream HTTP-. .

+3

f ifstream file, socket.

HTTP GET Request, , .

boost::asio . [Examples]

Since the web server is located on your local network (judging by the IP address - I’m not sure why people still insist on using those who are on these foamy days of DNS, but this may be possible), maybe you can connect a file a system containing the desired file on your local computer using NFS or similar. Then you can perform file operations, for example, reading using ifstream.

+2
source

ifstream only works with files available on the file system, not on web servers.

0
source

Source: https://habr.com/ru/post/1784939/


All Articles