Changeset cc6fdf8 for lib/http_client.h
- Timestamp:
- 2012-12-22T00:14:26Z (11 years ago)
- Branches:
- master
- Children:
- 7d5afa6
- Parents:
- 92d3044 (diff), 573e274 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/http_client.h
r92d3044 rcc6fdf8 26 26 /* http_client allows you to talk (asynchronously, again) to HTTP servers. 27 27 In the "background" it will send the whole query and wait for a complete 28 response to come back. Right now it's only used by the MSN Passport 29 authentication code, but it might be useful for other things too (for 30 example the AIM usericon patch uses this so icons can be stored on 31 webservers instead of the local filesystem). 28 response to come back. Initially written for MS Passport authentication, 29 but used for many other things now like OAuth and Twitter. 32 30 33 Didn't test this too much, but it seems to work well. Just don't look 34 at the code that handles HTTP 30x redirects. ;-) The function is 35 probably not very useful for downloading lots of data since it keeps 36 everything in a memory buffer until the download is completed (and 37 can't pass any data or whatever before then). It's very useful for 38 doing quick requests without blocking the whole program, though. */ 31 It's very useful for doing quick requests without blocking the whole 32 program. Unfortunately it doesn't support fancy stuff like HTTP keep- 33 alives. */ 39 34 40 35 #include <glib.h> … … 42 37 43 38 struct http_request; 39 40 typedef enum http_client_flags 41 { 42 HTTPC_STREAMING = 1, 43 HTTPC_EOF = 2, 44 45 /* Let's reserve 0x1000000+ for lib users. */ 46 } http_client_flags_t; 44 47 45 48 /* Your callback function should look like this: */ … … 53 56 char *request; /* The request to send to the server. */ 54 57 int request_length; /* Its size. */ 55 int status_code;/* The numeric HTTP status code. (Or -158 short status_code; /* The numeric HTTP status code. (Or -1 56 59 if something really went wrong) */ 57 60 char *status_string; /* The error text. */ … … 59 62 char *reply_body; 60 63 int body_size; /* The number of bytes in reply_body. */ 61 /* int finished; Set to non-0 if the request was completed 62 successfully. */ 63 int redir_ttl; /* You can set it to 0 if you don't want 64 short redir_ttl; /* You can set it to 0 if you don't want 64 65 http_client to follow them. */ 66 67 http_client_flags_t flags; 65 68 66 69 http_input_function func; … … 68 71 69 72 /* Please don't touch the things down here, you shouldn't need them. */ 70 71 73 void *ssl; 72 74 int fd; … … 75 77 int bytes_written; 76 78 int bytes_read; 79 80 /* Used in streaming mode. Caller should read from reply_body. */ 81 char *sbuf; 82 size_t sblen; 77 83 }; 78 84 … … 83 89 struct http_request *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ); 84 90 struct http_request *http_dorequest_url( char *url_string, http_input_function func, gpointer data ); 91 92 /* For streaming connections only; flushes len bytes at the start of the buffer. */ 93 void http_flush_bytes( struct http_request *req, size_t len ); 94 void http_close( struct http_request *req );
Note: See TracChangeset
for help on using the changeset viewer.