mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-08 14:41:55 +00:00
added data:// facility
This commit is contained in:
@@ -92,7 +92,7 @@ void uwsgi_ini_config(char *file, char *magic_table[]) {
|
||||
char *section_asked = "uwsgi";
|
||||
char *colon;
|
||||
|
||||
if (!uwsgi_startswith(file, "http://", 7)) {
|
||||
if (!uwsgi_startswith(file, "http://", 7) || !uwsgi_startswith(file, "data://", 7) || !uwsgi_startswith(file, "sym://", 6) ) {
|
||||
colon = uwsgi_get_last_char(file, '/');
|
||||
colon = uwsgi_get_last_char(colon, ':');
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ void uwsgi_json_config(char *file, char *magic_table[]) {
|
||||
char *colon;
|
||||
int i;
|
||||
|
||||
if (!uwsgi_startswith(file, "http://", 7)) {
|
||||
if (!uwsgi_startswith(file, "http://", 7) || !uwsgi_startswith(file, "data://", 7) || !uwsgi_startswith(file, "sym://", 6)) {
|
||||
colon = uwsgi_get_last_char(file, '/');
|
||||
colon = uwsgi_get_last_char(colon, ':');
|
||||
}
|
||||
|
||||
@@ -1793,6 +1793,63 @@ char *uwsgi_open_and_read(char *url, int *size, int add_zero, char *magic_table[
|
||||
#endif
|
||||
else if (!strncmp("data://", url, 7)) {
|
||||
fd = open(uwsgi.binary_path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
uwsgi_error_open(uwsgi.binary_path);
|
||||
exit(1);
|
||||
}
|
||||
int slot = atoi(url+7);
|
||||
if (slot < 0) {
|
||||
uwsgi_log("invalid binary data slot requested\n");
|
||||
exit(1);
|
||||
}
|
||||
uwsgi_log("requesting binary data slot %d\n", slot);
|
||||
off_t fo = lseek(fd, 0, SEEK_END);
|
||||
if (fo < 0) {
|
||||
uwsgi_error("lseek()");
|
||||
uwsgi_log("invalid binary data slot requested\n");
|
||||
exit(1);
|
||||
}
|
||||
int i = 0;
|
||||
uint64_t datasize = 0;
|
||||
for(i=0;i<=slot;i++) {
|
||||
fo = lseek(fd, -9, SEEK_CUR);
|
||||
if (fo < 0) {
|
||||
uwsgi_error("lseek()");
|
||||
uwsgi_log("invalid binary data slot requested\n");
|
||||
exit(1);
|
||||
}
|
||||
ssize_t len = read(fd, &datasize, 8);
|
||||
if (len != 8) {
|
||||
uwsgi_error("read()");
|
||||
uwsgi_log("invalid binary data slot requested\n");
|
||||
exit(1);
|
||||
}
|
||||
if (datasize == 0) {
|
||||
uwsgi_log("0 size binary data !!!\n");
|
||||
exit(1);
|
||||
}
|
||||
fo = lseek(fd, -(datasize+9), SEEK_CUR);
|
||||
if (fo < 0) {
|
||||
uwsgi_error("lseek()");
|
||||
uwsgi_log("invalid binary data slot requested\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (i == slot) {
|
||||
*size = datasize;
|
||||
if (add_zero) {
|
||||
*size+=1;
|
||||
}
|
||||
buffer = uwsgi_malloc(*size);
|
||||
memset(buffer, 0, *size);
|
||||
len = read(fd, buffer, datasize);
|
||||
if (len != (ssize_t) datasize) {
|
||||
uwsgi_error("read()");
|
||||
uwsgi_log("invalid binary data slot requested\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strncmp("sym://", url, 6)) {
|
||||
char *symbol = uwsgi_concat3("_binary_", url+6, "_start") ;
|
||||
|
||||
@@ -26,7 +26,7 @@ void uwsgi_xml_config(char *filename, struct wsgi_request *wsgi_req, int app_tag
|
||||
char *xml_content;
|
||||
int xml_size = 0;
|
||||
|
||||
if (!uwsgi_startswith(filename, "http://", 7)) {
|
||||
if (!uwsgi_startswith(filename, "http://", 7) || !uwsgi_startswith(filename, "data://", 7) || !uwsgi_startswith(filename, "sym://", 6)) {
|
||||
colon = uwsgi_get_last_char(filename, '/');
|
||||
colon = uwsgi_get_last_char(colon, ':');
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void uwsgi_yaml_config(char *file, char *magic_table[]) {
|
||||
char *section_asked = "uwsgi";
|
||||
char *colon;
|
||||
|
||||
if (!uwsgi_startswith(file, "http://", 7)) {
|
||||
if (!uwsgi_startswith(file, "http://", 7) || !uwsgi_startswith(file, "data://", 7) || !uwsgi_startswith(file, "sym://", 6)) {
|
||||
colon = uwsgi_get_last_char(file, '/');
|
||||
colon = uwsgi_get_last_char(colon, ':');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user