[En-Nut-Discussion] httpd with dynamically generated text or binary files

Hugo Simon hugo.simon at gmx.de
Thu Oct 20 22:40:11 CEST 2005


Hi,

I want to create a webserver application where a user can download text or
binary files which does not lay in the ROM filessystem but are generated on
the fly from some data the nut has collected.

First approach was to use NutHttpProcessRequest() and register a CGI which
generates the file. It works if the user clicks the link to the file but
didn't work if he choose to "save destination to file". Why?

I think it has something to do with that the "file" have to be in cgi-bin.
Ist there a way to register a normal URL to a function?

Here is the function to create a file via CGI:

int LoadASCIIFile(FILE *stream, REQUEST *req)
{
 fputs_P(PSTR("HTTP/1.0 200 OK\r\n"
              "Server: shServer\r\n" "Content-Length: %ld\r\n"
              "Connection: close\r\n\r\n"),stream);

 fprintf(serout,"LoadASCII Method = %i, %s\n",req->req_method,req->req_url);
 fputs_P(PSTR("Blalaber\nLine 2\n"),stream);
 fflush(stream);
 return 0;
}

Thank you for help.
Bye
Thorsten




More information about the En-Nut-Discussion mailing list