Make it easier to share whole files
@hadess
Submitted by Bastien Nocera Assigned to libsoup-maint@gnome.bugs
Link to original bug (#763369)
Description
It would be nice for SoupSession to implement more of the possible HTTP requests, such as answering range requests itself, without the need to use a mapped file.
For example, a naive implementation to serve a file would be: if (msg->method == SOUP_METHOD_GET) { soup_message_set_response (msg, file->mime_type, SOUP_MEMORY_STATIC, g_mapped_file_get_contents (file->mapped_file), g_mapped_file_get_length (file->mapped_file)); } else { soup_message_headers_set_content_type (msg->response_headers, file->mime_type, NULL);
soup_message_headers_set_content_length (msg->response_headers,
g_mapped_file_get_length (file->mapped_file));
}
This won't work on non-local files that can't be mmapped. It would be good if SoupSession could handle that for the developer.
Version: 2.39.x