59 const char *slash = strrchr(
filename,
'/');
95 const char *http_header;
97 unsigned long long int length;
102 if (http_header == NULL)
103 http_header =
"text/plain";
111 if (http_header == NULL) {
114 length =
strtoull(http_header, NULL, 10);
119 "Content-Disposition");
120 if (http_header != NULL) {
121 lwc_string *filename_value;
132 corestring_lwc_filename, &filename_value);
135 lwc_string_data(filename_value));
136 lwc_string_unref(filename_value);
184 switch (event->
type) {
253 ctx = malloc(
sizeof(*
ctx));
303unsigned long long int
nserror http_parse_content_disposition(const char *header_value, http_content_disposition **result)
Parse an HTTP Content-Disposition header value.
void http_content_disposition_destroy(http_content_disposition *victim)
Destroy a content disposition object.
nserror http_parse_content_type(const char *header_value, http_content_type **result)
Parse an HTTP Content-Type header value.
void http_content_type_destroy(http_content_type *victim)
Destroy a content type object.
content_type
The type of a content.
Useful interned string pointers (interface).
static nserror download_callback(llcache_handle *handle, const llcache_event *event, void *pw)
Callback for low-level cache events.
void download_context_destroy(download_context *ctx)
Destroy a download context.
nsurl * download_context_get_url(const download_context *ctx)
Retrieve the URL for a download.
const char * download_context_get_filename(const download_context *ctx)
Retrieve the filename for a download.
void download_context_abort(download_context *ctx)
Abort a download fetch.
static char * download_parse_filename(const char *filename)
Parse a filename parameter value.
static char * download_default_filename(nsurl *url)
Compute a default filename for a download.
const char * download_context_get_mime_type(const download_context *ctx)
Retrieve the MIME type for a download.
static nserror download_context_process_headers(download_context *ctx)
Process fetch headers for a download context.
nserror download_context_create(llcache_handle *llcache, struct gui_window *parent)
Create a download context.
unsigned long long int download_context_get_total_length(const download_context *ctx)
Retrieve total byte length of download.
Core download context (interface)
nserror
Enumeration of error codes.
@ NSERROR_NOMEM
Memory exhaustion.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
HTTP header parsing functions.
Interface to platform-specific download operations.
static struct llcache_s * llcache
low level cache state
nserror llcache_handle_abort(llcache_handle *handle)
Abort a low-level fetch, informing all users of this action.
nsurl * llcache_handle_get_url(const llcache_handle *handle)
Retrieve the post-redirect URL of a low-level cache object.
const char * llcache_handle_get_header(const llcache_handle *handle, const char *key)
Retrieve a header value associated with a low-level cache object.
nserror llcache_handle_change_callback(llcache_handle *handle, llcache_handle_callback cb, void *pw)
Change the callback associated with a low-level cache handle.
nserror llcache_handle_release(llcache_handle *handle)
Release a low-level cache handle.
Low-level resource cache (interface)
@ LLCACHE_EVENT_DONE
Finished fetching data.
@ LLCACHE_EVENT_ERROR
An error occurred during fetch.
@ LLCACHE_EVENT_GOT_CERTS
SSL certificates arrived.
@ LLCACHE_EVENT_REDIRECT
Fetch URL redirect occured.
@ LLCACHE_EVENT_PROGRESS
Fetch progress update.
@ LLCACHE_EVENT_HAD_HEADERS
Received all headers.
@ LLCACHE_EVENT_HAD_DATA
Received some data.
nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
Attempt to find a nice filename for a URL.
struct nsurl nsurl
NetSurf URL object.
nserror http_parameter_list_find_item(const http_parameter *list, lwc_string *name, lwc_string **value)
Find a named item in an HTTP parameter list.
Interface to utility string handling.
A context for a download.
char * filename
Suggested filename.
llcache_handle * llcache
Low-level cache handle.
struct gui_download_window * window
GUI download window.
lwc_string * mime_type
MIME type of download.
unsigned long long int total_length
Length of data, in bytes.
struct gui_window * parent
Parent window.
nserror(* data)(struct gui_download_window *dw, const char *data, unsigned int size)
void(* done)(struct gui_download_window *dw)
void(* error)(struct gui_download_window *dw, const char *error_msg)
struct gui_download_window *(* create)(struct download_context *ctx, struct gui_window *parent)
context for each download.
struct download_context * ctx
Associated context, or 0 if the fetch has completed or aborted.
first entry in window list
http_parameter * parameters
struct llcache_event::@124::@126 error
const char * msg
Error message.
struct llcache_event::@124::@125 data
Received data.
size_t len
Byte length of buffer.
llcache_event_type type
Type of event.
const uint8_t * buf
Buffer of data.
Handle to low-level cache object.
struct gui_download_table * download
Download table.
Interface to a number of general purpose functionality.
unsigned long long int strtoull(const char *nptr, char **endptr, int base)
string to unsigned long long