libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] Handling range requests with libmicrohttpd


From: rsanchez1990
Subject: [libmicrohttpd] Handling range requests with libmicrohttpd
Date: Tue, 28 Dec 2010 17:18:43 -0500

Hello,

I'm using libmicrohttpd as a streaming server that serves audio files to an HTML5 Audio object. It's working fine for small files, but for songs that are longer and have larger files, the audio object sends a range request and because I'm not handling the request properly, the audio object fails. I am using MHD_USE_THREAD_PER_CONNECTION in MHD_start_daemon(), and I create a response like this:

response = MHD_create_response_from_callback(sizeof(char)*fileSize, 32 * 1024, &file_reader, filePointer, &file_free_callback);

My file_reader is this:

static ssize_t file_reader(void *cls, uint64_t pos, char *buffer, size_t max)
{
    FILE *fp = (FILE*) cls;
    (void) fseek(fp, pos, SEEK_SET);
    return fread(buffer, 1, max, fp);
}

When the second request comes in, the first request is still in the process of reading and serving the file, and I get this header:

Range: bytes=127023-

So what's the proper way of handling a range request? I'm very stuck on this and would appreciate any assistance. Thanks.


--
Roberto Sanchez




reply via email to

[Prev in Thread] Current Thread [Next in Thread]