2013-11-05 18:02:59 +01:00
|
|
|
|
2015-03-20 13:04:14 +01:00
|
|
|
get(*url, identifier, flags, *add_header);
|
2013-11-05 18:02:59 +01:00
|
|
|
*url = pointer to ASCIIZ URL
|
2015-08-24 15:43:34 +02:00
|
|
|
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
|
|
|
|
flags = bit flags (see end of this document).
|
2013-11-13 19:25:47 +01:00
|
|
|
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
2013-11-16 21:22:44 +01:00
|
|
|
Every additional parameter must end with CR LF bytes, including the last line.
|
2013-11-05 18:02:59 +01:00
|
|
|
Initiates a HTTP connection, using 'GET' method.
|
|
|
|
- returns 0 on error, identifier otherwise.
|
|
|
|
|
2015-03-20 13:04:14 +01:00
|
|
|
head(*url, identifier, flags, *add_header);
|
2013-11-05 18:02:59 +01:00
|
|
|
*url = pointer to ASCIIZ URL
|
2015-08-24 15:43:34 +02:00
|
|
|
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
|
|
|
|
flags = bit flags (see end of this document).
|
2013-11-13 19:25:47 +01:00
|
|
|
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
2013-11-16 21:22:44 +01:00
|
|
|
Every additional parameter must end with CR LF bytes, including the last line.
|
2013-11-05 18:02:59 +01:00
|
|
|
Initiate a HTTP connection, using 'HEAD' method.
|
|
|
|
- returns 0 on error, identifier otherwise
|
|
|
|
|
2015-03-20 13:04:14 +01:00
|
|
|
post(*url, identifier, flags, *add_header, *content-type, content-length);
|
2013-11-05 18:02:59 +01:00
|
|
|
*url = pointer to ASCIIZ URL
|
2015-08-24 15:43:34 +02:00
|
|
|
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
|
|
|
|
flags = bit flags (see end of this document).
|
2013-11-13 19:25:47 +01:00
|
|
|
*add_header = pointer to ASCIIZ additional header parameters, or null for none.
|
2013-11-16 21:22:44 +01:00
|
|
|
Every additional parameter must end with CR LF bytes, including the last line.
|
2013-11-05 18:02:59 +01:00
|
|
|
*content-type = pointer to ASCIIZ string containing content type.
|
|
|
|
content-length = length of the content (in bytes).
|
|
|
|
Initiate a HTTP connection, using 'POST' method.
|
|
|
|
The content itself must be send to the socket (which you can find in the structure),
|
|
|
|
using system function 75, 6.
|
|
|
|
- returns 0 on error, identifier otherwise
|
|
|
|
|
2014-07-16 16:11:19 +02:00
|
|
|
receive(identifier);
|
2013-11-05 18:02:59 +01:00
|
|
|
identifier = identifier which one of the previous functions returned
|
|
|
|
This procedure will handle all incoming data for a connection and place it in the buffer.
|
|
|
|
As long as the procedure expects more data, -1 is returned and the procedure must be called again.
|
|
|
|
- When transfer is done, the procedure will return 0.
|
2015-08-17 12:33:23 +02:00
|
|
|
The receive procedure is non-blocking by default, but can be made to block by setting FLAG_BLOCK.
|
2013-11-05 18:02:59 +01:00
|
|
|
|
2014-01-27 22:15:30 +01:00
|
|
|
The HTTP header is placed together with some flags and other attributes in the http_msg structure.
|
2013-11-05 18:02:59 +01:00
|
|
|
This structure is defined in http.inc (and not copied here because it might still change.)
|
|
|
|
The identifier used by the functions is actually a pointer to this structure.
|
|
|
|
In the dword named .flags, the library will set various bit-flags indicating the status of the process.
|
|
|
|
(When a transfer is done, one should check these bit-flags to find out if the transfer was error-free.)
|
2014-01-27 22:15:30 +01:00
|
|
|
The HTTP header is placed at the end of this structure. The content is placed in another buffer.
|
2013-11-05 18:02:59 +01:00
|
|
|
The dword .status contains the status code received from the server (e.g. 200 for OK).
|
|
|
|
In header_length you'll find the length of the header as soon as it has been received.
|
2014-01-27 22:15:30 +01:00
|
|
|
In content_ptr you'll find a pointer to the actual content.
|
|
|
|
In content_length you'll find the length of the content.
|
2014-06-21 20:31:41 +02:00
|
|
|
In content_received, you'll find the number of content bytes already received.
|
|
|
|
|
2014-07-16 16:11:19 +02:00
|
|
|
send(identifier, *dataptr, datalength);
|
|
|
|
identifier = identifier which one of the previous functions returned
|
|
|
|
*dataptr = pointer to the data you want to send
|
|
|
|
datalength = length of the data to send (in bytes)
|
|
|
|
This procedure can be used to send data to the server (POST)
|
|
|
|
- returns number of bytes sent, -1 on error
|
2015-08-17 12:33:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
User flags:
|
2014-07-16 16:11:19 +02:00
|
|
|
|
2015-08-24 15:43:34 +02:00
|
|
|
For the flag codes themselves, see http.inc file.
|
|
|
|
|
2015-08-17 12:33:23 +02:00
|
|
|
FLAG_KEEPALIVE will keep the connection open after first GET/POST/.. so you can send a second request on the same TCP session.
|
|
|
|
In this case, the session must be closed manually when done by using the exported disconnect() function.
|
|
|
|
|
|
|
|
FLAG_STREAM will force receive() to put the received content in a series of fixed size buffers, instead of everything in one big buffer.
|
|
|
|
This can be used for example to receive an internet radio stream,
|
|
|
|
but also to download larger files for which it does not make sense to put them completely in RAM first.
|
|
|
|
|
|
|
|
FLAG_REUSE_BUFFER is to be used in combination with FLAG_STREAM and will make receive() function re-use the same buffer.
|
|
|
|
This, for example, can be used when downloading a file straight to disk.
|
|
|
|
|
|
|
|
FLAG_BLOCK will make receive() function blocking. This is only to be used when receiving one file from a thread that has no other work.
|
|
|
|
If however, you want to receive multiple files, or do other things in the program mainloop,
|
|
|
|
you should use system function 10 or 23 to wait for network event before calling one or more receive() functions.
|