HttpFileRequest

From TrillWiki

Jump to: navigation, search

The httpFileRequest function will grab an http file and return the data so that it may be used from within a plugin.

Compatibility: 2.0 and higher

Contents

Syntax

plugin_send(MYGUID, "httpFileRequest", struct http_request_t *);

Note that all Trillian functions and notifications begin with a lower-case letter, despite the Wiki requirement that all pages start with a capital letter.

Parameters

HttpFileRequest utilitizes the http_request_t structure.

struct http_request_t 
{ 
    unsigned int                struct_size; 

    char                        *url; 

    ttkCallback                 callback; 
    void                        *data;  

    /* 3.0 
     */ 

    int                         content_length; 

    char                        *content_type; 
    char                        *content_data; 

    /* 3.1 
     */ 

    char                        *command; 
    unsigned int                flags; 

    unsigned char               *http_header; 
    int                         http_header_len; 

    int                         pi_use; 
    int                         pi_type; 
    int                         pi_use_authentication; 

    char                        *pi_server; 
    char                        *pi_port; 
    char                        *pi_username; 
    char                        *pi_password; 
};


url
The file location to download. This must be a full URL including port eg. http://www.example.com/path/file.html
callback
The callback to receive the http notifications.
data
The data to send along with the above callback.


Return Value

Negative value on error, 0 on success.

Remarks

Be careful when using this function. If the plugin gets unloaded while a HTTP request is still running in the background, Trillian will crash. Also, keep in mind that HTTP requests are performed in a separate thread.


See also: HTTP Notifications

Personal tools