Hi All. We desire to set up file upload/download feature with a HTTP-Web-Server where the client runs in an embedded-environment, and thus wish to achieve this using the absolute basic primitives - socket programming (on the client-side that is).
We have been able to achieve the download functionality. For brevity, this is how we do it :: ################################################################## *telnet localhost 80* Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. *GET /1/test_download_file.txt HTTP/1.0\r\n\r\n* HTTP/1.1 200 OK Date: Sun, 09 Aug 2015 16:50:54 GMT Server: Apache/2.4.7 (Ubuntu) Last-Modified: Sun, 09 Aug 2015 16:50:23 GMT ETag: "1d-51ce3aa4aa242" Accept-Ranges: bytes Content-Length: 29 Connection: close Content-Type: text/plain Testing download success !!! Connection closed by foreign host. ################################################################## We tested our code on a local HTTP-server, and the same code is serving us well with the production HTTP-server. When we try the same for file-uploading, this is what we get :: ################################################################## *telnet localhost 80* Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. *PUT /1/test_upload_file.txt HTTP/1.0\r\n\r\n* *Content-Length: 41234* HTTP/1.1 405 Method Not Allowed Date: Sun, 09 Aug 2015 16:58:38 GMT Server: Apache/2.4.7 (Ubuntu) Allow: GET,HEAD,POST,OPTIONS Content-Length: 317 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>405 Method Not Allowed</title> </head><body> <h1>Method Not Allowed</h1> <p>The requested method PUT is not allowed for the URL /1/test_upload_file.txt.</p> <hr> <address>Apache/2.4.7 (Ubuntu) Server at 127.0.1.1 Port 80</address> </body></html> Connection closed by foreign host. ################################################################## Following is the Virtual-Host configuration :: ################################################################## <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /> AllowOverride All <Limit GET HEAD POST PUT DELETE OPTIONS> Order Allow,Deny Allow from all </Limit> </Directory> # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> ################################################################## Please note that in the test-environment, the http-server is running on Ubuntu 14.04 on a 32-bit machine desktop. (Just to re-iterate, the file-download works using the absolute basics, but the file-upload does not). I have tried googling and tried whatever it threw us, but I am unable to make the file-upload work. We will be grateful if we could let be known where I am making the mistake. Looking forward to some help ... Thanks and Regards, Ajay