implemented Mono send file from handle

This commit is contained in:
Unbit
2013-02-27 08:30:14 +01:00
parent b6bdafa669
commit e517bcea7c
2 changed files with 14 additions and 1 deletions
+10
View File
@@ -146,6 +146,15 @@ static void uwsgi_mono_method_FlushResponse(MonoObject *this, int is_final) {
uwsgi_response_write_body_do(wsgi_req, "", 0);
}
static void uwsgi_mono_method_SendResponseFromFd(MonoObject *this, int fd, long offset, long len) {
struct wsgi_request *wsgi_req = current_wsgi_req();
wsgi_req->sendfile_fd = fd;
if (fd >= 0) {
uwsgi_response_sendfile_do(wsgi_req, fd, offset, len);
}
wsgi_req->sendfile_fd = -1;
}
static void uwsgi_mono_method_SendResponseFromFile(MonoObject *this, MonoString *filename, long offset, long len) {
struct wsgi_request *wsgi_req = current_wsgi_req();
int fd = open(mono_string_to_utf8(filename), O_RDONLY);
@@ -206,6 +215,7 @@ static void uwsgi_mono_add_internal_calls() {
mono_add_internal_call("uwsgi.uWSGIRequest::GetFilePath", uwsgi_mono_method_GetFilePath);
mono_add_internal_call("uwsgi.uWSGIRequest::GetUriPath", uwsgi_mono_method_GetUriPath);
mono_add_internal_call("uwsgi.uWSGIRequest::SendResponseFromFile", uwsgi_mono_method_SendResponseFromFile);
mono_add_internal_call("uwsgi.uWSGIRequest::SendResponseFromFd", uwsgi_mono_method_SendResponseFromFd);
mono_add_internal_call("uwsgi.uWSGIRequest::GetHeaderByName", uwsgi_mono_method_GetHeaderByName);
mono_add_internal_call("uwsgi.uWSGIRequest::ReadEntityBody", uwsgi_mono_method_ReadEntityBody);
mono_add_internal_call("uwsgi.uWSGIRequest::GetTotalEntityBodyLength", uwsgi_mono_method_GetTotalEntityBodyLength);
+4 -1
View File
@@ -93,8 +93,11 @@ namespace uwsgi {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern public override void SendResponseFromMemory(byte[] chunk, int length);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern public void SendResponseFromFd(int fd, long offset, long length);
public override void SendResponseFromFile (IntPtr handle, long offset, long length) {
Console.WriteLine("sending a file");
SendResponseFromFd(handle.ToInt32(), offset, length);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]