Fix HTTP matching
This commit is contained in:
parent
ba676cda0e
commit
24611c1290
14
cmd/main.c
14
cmd/main.c
@ -10,22 +10,16 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
http_method_t http_methods[] = {
|
http_method_t http_methods[] = {
|
||||||
{ "GET / ", http_index },
|
|
||||||
{ "GET /snapshot ", http_snapshot },
|
|
||||||
{ "GET /snapshot?", http_snapshot },
|
{ "GET /snapshot?", http_snapshot },
|
||||||
{ "GET /stream ", http_stream },
|
|
||||||
{ "GET /stream?", http_stream },
|
{ "GET /stream?", http_stream },
|
||||||
{ "GET /?action=snapshot", http_snapshot },
|
{ "GET /?action=snapshot", http_snapshot },
|
||||||
{ "GET /?action=snapshot?", http_snapshot },
|
|
||||||
{ "GET /?action=stream", http_stream },
|
{ "GET /?action=stream", http_stream },
|
||||||
{ "GET /?action=stream?", http_stream },
|
|
||||||
{ "GET /video ", http_video_html },
|
|
||||||
{ "GET /video?", http_video_html },
|
{ "GET /video?", http_video_html },
|
||||||
{ "GET /video.h264 ", http_video },
|
{ "GET /video.h264?", http_h264_video },
|
||||||
{ "GET /video.h264?", http_video },
|
{ "GET /video.mkv?", http_mkv_video },
|
||||||
{ "GET /jmuxer.min.js ", http_jmuxer_js },
|
|
||||||
{ "GET /jmuxer.min.js?", http_jmuxer_js },
|
{ "GET /jmuxer.min.js?", http_jmuxer_js },
|
||||||
{ NULL, NULL }
|
{ "GET /?", http_index },
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
camera_options_t camera_options = {
|
camera_options_t camera_options = {
|
||||||
|
@ -67,7 +67,14 @@ static void http_process(http_worker_t *worker, FILE *stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; worker->methods[i].name; i++) {
|
for (int i = 0; worker->methods[i].name; i++) {
|
||||||
if (strstr(worker->client_method, worker->methods[i].name)) {
|
const char *name = worker->methods[i].name;
|
||||||
|
int nlen = strlen(worker->methods[i].name);
|
||||||
|
|
||||||
|
if (strncmp(worker->client_method, name, nlen-1))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// allow last character to match `?` or ` `
|
||||||
|
if (worker->client_method[nlen-1] == name[nlen-1] || name[nlen-1] == '?' && worker->client_method[nlen-1] == ' ') {
|
||||||
worker->methods[i].func(worker, stream);
|
worker->methods[i].func(worker, stream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user