How do I copy a file on a http server, from the client? - c++

In the past I used an ftp server, connected via "ftp" from the client and "GET" to copy one file from the remote machine to the local machine.
Is it possible to do the same but with the server only running a http server?
Server: GoAhead Web Server.
Both client and http server on Windows.
The copy can be either initiated from the browser or if need a separate program can be written on the client. (i.e. - any windows api calls to copy a file from http server?)
(Also, the files may not be in the http root web directory but somewhere else on the server....can that happen?)

HTTP servers will only serve up files that are located within the site's document root. If you want to get at files that are outside the document root, you'll have to have a script serve up that file from the server (php, perl, cgi, etc...), or find some way of getting that file "inside" the document root.
To download files within the site's document root, you just hit a url pointing at that file - that's the core point of HTTP - you're just downloading content from the site.
HTTP servers will also not accept uploads without an intermediate script to handle it. If they did, you could upload any file you wanted to any server, anywhere.

What others mentioned about HTTP servers is true, but GoAhead Web Server is not a only a HTTP server. It provides many other features on top of that. And file upload seems possible, with help of a patch. More info:
https://embedthis.com/goahead/

Use WebDav for this purpose.

Related

How to download file when the application(MuleSoft 3.9) is deployed on Server?

I have created an application in Mule 3.9 which coverts Json to Excel. I need to deploy it on server,so that it can be used by a larger audience.
The code uses HTTP Connector-->Transformer-->File Connector.
I need the application to work in such a way that when the application is deployed on Pivotal Cloud Foundry (PCF), anyone who sends request to this application via postman, will have the excel file downloaded to their local machine.
How can I achieve this?
PS: Since everyone will not be having access to login to the server and access the file, somehow getting the Excel sheet on the requesters local machine is the only way I can think of. Any other suggestions are welcome.
Request: JSON Request sent on Postman
Response: Converted Excel Sheet
Probably there is no way the File connector can reach out the client local machine, so I would rule that out. The File connector will have access to the file system of the server in which it is deployed.
The usual way to do this is to set the file, in this case the Excel payload resulting of the Transformer, at the end of the flow so it is returned to Postman as the body of the HTTP response. You might need to set the right content type. Postman should be able to handle a binary response. No file handling involved.

Could I get html of website without server knowing?

Is it possible to get html of webpage without server knowing this. I mean without http request. Aren't all servers connected into internet. If I am right, it is just like filesystem: servers are just child folders and internet is the main folder(or a disk). So if i am correct the whole internet is pretty similar to a filesystem. So (only if i am right) it could be possible, to navigate to one server, and open some random html file in it, just like you open a file in a folder in File explorer. So I am asking: is it possible, and if it is how could I do it.
You're right in that all servers are connected to the internet (although that's something of an oversimplification, the details aren't really relevant here). However, while those servers may have their own internal filesystem, you can't (generally speaking) browse them like a filesystem locally connected to your computer. Your computer and the server need to send data back and forth to get any files. The way this is done is with a protocol. HTTP (HyperText Transport Protocol) is one such protocol. If the server also accepts another protocol, such as FTP (File Transfer Protocol), you may be able to avoid using HTTP and get the files more directly, but in any case, the server still needs to send your computer data, which may be logged.
Is it possible to get html of webpage without server knowing this. I mean without http request.
Normally no, but under certain circumstances, yes. It's a http request (or whatever protocol the resource uses) still though.
Consider a corporate proxy. It downloads a page one time. The page may have a timestamp in it telling the proxy for how long it's allowed to cache it. All subsequent requests for that page from within the corporation may be served by the proxy server only - and the original server out there on the internet who published the webpage in the first place wouldn't know anything about it.
Aren't all servers connected into internet
No.
Many servers providing services to individuals and corporations are not. Some (many) have internet access but do not listen for incomming requests. Others have no internet access whatsoever.
If I am right, it is just like filesystem: servers are just child folders and internet is the main folder(or a disk).
Well... perhaps it could be viewed that way.
So if i am correct the whole internet is pretty similar to a filesystem. So (only if i am right) it could be possible, to navigate to one server, and open some random html file in it, just like you open a file in a folder in File explorer.
So I am asking: is it possible, and if it is how could I do it.
Kind of. You could use a webcrawler to scan a site but unless the server is improperly setup, you'll only have access to what the person behind the server wants you to have access to - and there are usually logs telling that person who (what IP number) did what.
A web server is only going to be listening for HTTP requests and it will only deliver the pages it is setup to deliver. A server may support additional protocols like FTP but again it will only serve up the files it has been told to.
If you want access to a remote computers filling system then you will need a different protocol and access rights on the remote machine. Have a look at SMB 3.0 for ideas.

Qt+wasm client-server communication

In Qt webassembly documentation there is a mention, than one can use QNetworkAccessManager for HTTP communication with the server that hosts my website. The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
Yes. Your server program runs a QApplication, and the single instance of that class could get that URL.
In other words, you'll document that your C++ program (the executable file obtained by compilation, e.g. with GCC) foo would accept some --server-url argument, and you would start foo --server-url http://example.com/somestrangeurl/
Please notice that WebAssembly is often running inside Web browsers (that is, inside Web or HTTP clients). Most HTTP servers (e.g. lighttpd) are running on Linux OS (and you might use Wt or libonion or some other HTTP server library for them, if you have to code your HTTP server from scratch).

apache if header contains then pass it to another url(jboss server)

I want to check a http header in request, which is received on apache 2.2 and if it contains that header I would like to fire a new request to jboss whose ip is different from apache server's. Is this possible?
I have seen this doc
enter link description here
In the above link I can check if header exist, but how to create new request to another server with same header forwarded.
Any help is appreciated.
What you suggest would send a redirect response to the browser, and it would be the browser who would end up visiting your Jboss server.
I'm not sure if that's precisely what you want, but sounds like what you want is to get Apache to do that request to Jboss and then send the response to the browser. This would be the typical scenario with a web server (apache) and an application server (Jboss) where you normally don't access the application server directly.
What you want to make this work in apache is a reverse proxy.

How to upload, download files in server side web serivce

How do I upload files in a REST web service? The Java Swing application will call REST web service to use the upload method.
I used apache.commons.fileupload but it is for web-based applications.
How do I download files? I used FileReader and PrintWriter. it is ok for other files, but I have a problem with pictures and zip files. What lib do I need to use to download binary files, pictures, zip, HTML, etc.?
https://stackoverflow.com/a/32253028/15789
For anyone who stumbles upon this page - the above may help. It is an example REST service that receives bytes of a file and sends zipped bytes in response. Using JAX-RS Client to send request and receive response.