Re: How can I POST form-data
Poonam Mehtani writes:
> I have been trying to use the library libwww and in relation to that I have a couple of questions.
> I have an application in which I need to submit a HTML form to retrieve some document. Instead of actually filling the form I need to sen
d the data to the query server through a command. For that I tried to use the
Command Line Tool to send form data by appending query strin
g to the URL but it didn't work.This was tried with a form using GET method.
I am not sure what the problem is here but it should be possible to send a
form encoded URL using the normal URL syntax with a "?" mark and a query
string in any GET request.
> In case of a form using POST method, I tried sending the data(name-value string) from a local file using -post and -dest options. It seem
s the data gets posted but I can not retrieve any document as a result of
that query. Could you tell me how this( POSTing the query string
and getting the HTML document as a result of the query) can be done ?
Each request object has an input stream and an output stream. The input stream
goes from the application and to the network, and the output stream goes from
the network and to the application. This way of using input and output differs
from for example Java where input means "read" and if people find it
confusing, I am willing to change it.
The output stream is normally set up by the stream stack when data starts to
arrive and we learn the media type and hence can select the proper converter
to handle the data. The input stream is normally assigned by the protocol
module, for example the HTTP module. The input stream can be used by the
application to send data to the network. However, as the application doesn't
knwo when the input data stream is ready for writing, you must instead
register a callback function which the protocol module can call when it is
ready for accepting data going to the network.
This is basically what the function HTUploadAnchor() in the HTAccess.c module
does. Here you can provide your own callback function that knows how to get
the data to send to the server. You can also have a look at the example
callback function HTUpload_callback() in the same module which shows you how
to write to a stream as this is not evident to do.
Henrik Frystyk Nielsen, <email@example.com>
World-Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA