mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
disabled file streaming for libmicrohttpd < 0.9.31-1
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8071 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
78604a831a
commit
4fa3d00f26
@ -10,10 +10,20 @@
|
|||||||
|
|
||||||
#include "api/JsonStream.h"
|
#include "api/JsonStream.h"
|
||||||
|
|
||||||
// old version number use hex, new ones use decimal numbers
|
#if MHD_VERSION < 0x00090000
|
||||||
// this is a hex number: 0x14 = 20
|
// very old version, probably v0.4.x on old debian/ubuntu
|
||||||
// -> 0.9.20
|
#define OLD_04_MHD_FIX
|
||||||
#if MHD_VERSION < 0x00091400
|
#endif
|
||||||
|
|
||||||
|
// filestreamer only works if a content reader callback is allowed to return 0
|
||||||
|
// this is allowed since libmicrohttpd revision 30402
|
||||||
|
#if MHD_VERSION >= 0x00093101 // 0.9.31-1
|
||||||
|
#define ENABLE_FILESTREAMER
|
||||||
|
#else
|
||||||
|
#warning libmicrohttpd is too old to support file streaming. upgrade to a newer version.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OLD_04_MHD_FIX
|
||||||
#define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL)
|
#define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL)
|
||||||
/**
|
/**
|
||||||
* Create a response object. The response object can be extended with
|
* Create a response object. The response object can be extended with
|
||||||
@ -163,6 +173,7 @@ public:
|
|||||||
ApiServer* mApiServer;
|
ApiServer* mApiServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef ENABLE_FILESTREAMER
|
||||||
class MHDFilestreamerHandler: public MHDHandlerBase
|
class MHDFilestreamerHandler: public MHDHandlerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -203,11 +214,8 @@ public:
|
|||||||
MHD_destroy_response(resp);
|
MHD_destroy_response(resp);
|
||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
}
|
}
|
||||||
#if MHD_VERSION >= 0x00091400
|
|
||||||
static ssize_t contentReadercallback(void *cls, uint64_t pos, char *buf, size_t max)
|
static ssize_t contentReadercallback(void *cls, uint64_t pos, char *buf, size_t max)
|
||||||
#else // old version
|
|
||||||
static int contentReadercallback(void *cls, uint64_t pos, char *buf, int max)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
MHDFilestreamerHandler* handler = (MHDFilestreamerHandler*)cls;
|
MHDFilestreamerHandler* handler = (MHDFilestreamerHandler*)cls;
|
||||||
if(pos >= handler->mSize)
|
if(pos >= handler->mSize)
|
||||||
@ -218,6 +226,7 @@ public:
|
|||||||
return size_to_send;
|
return size_to_send;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif // ENABLE_FILESTREAMER
|
||||||
|
|
||||||
ApiServerMHD::ApiServerMHD(std::string root_dir, uint16_t port):
|
ApiServerMHD::ApiServerMHD(std::string root_dir, uint16_t port):
|
||||||
mRootDir(root_dir), mPort(port),
|
mRootDir(root_dir), mPort(port),
|
||||||
@ -345,10 +354,15 @@ int ApiServerMHD::accessHandlerCallback(MHD_Connection *connection,
|
|||||||
// is it a call to the filestreamer?
|
// is it a call to the filestreamer?
|
||||||
if(strstr(url, FILESTREAMER_ENTRY_PATH) == url)
|
if(strstr(url, FILESTREAMER_ENTRY_PATH) == url)
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_FILESTREAMER
|
||||||
// create a new handler and store it in con_cls
|
// create a new handler and store it in con_cls
|
||||||
MHDHandlerBase* handler = new MHDFilestreamerHandler();
|
MHDHandlerBase* handler = new MHDFilestreamerHandler();
|
||||||
*con_cls = (void*) handler;
|
*con_cls = (void*) handler;
|
||||||
return handler->handleRequest(connection, url, method, version, upload_data, upload_data_size);
|
return handler->handleRequest(connection, url, method, version, upload_data, upload_data_size);
|
||||||
|
#else
|
||||||
|
sendMessage(connection, MHD_HTTP_NOT_FOUND, "The filestreamer is not available, because this executable was compiled with a too old version of libmicrohttpd.");
|
||||||
|
return MHD_YES;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// else server static files
|
// else server static files
|
||||||
|
Loading…
Reference in New Issue
Block a user