| 2842 | } |
| 2843 | |
| 2844 | static int rtsp_parse_request(HTTPContext *c) |
| 2845 | { |
| 2846 | const char *p, *p1, *p2; |
| 2847 | char cmd[32]; |
| 2848 | char url[1024]; |
| 2849 | char protocol[32]; |
| 2850 | char line[1024]; |
| 2851 | int len; |
| 2852 | RTSPMessageHeader header1, *header = &header1; |
| 2853 | |
| 2854 | c->buffer_ptr[0] = '\0'; |
| 2855 | p = c->buffer; |
| 2856 | |
| 2857 | get_word(cmd, sizeof(cmd), &p); |
| 2858 | get_word(url, sizeof(url), &p); |
| 2859 | get_word(protocol, sizeof(protocol), &p); |
| 2860 | |
| 2861 | av_strlcpy(c->method, cmd, sizeof(c->method)); |
| 2862 | av_strlcpy(c->url, url, sizeof(c->url)); |
| 2863 | av_strlcpy(c->protocol, protocol, sizeof(c->protocol)); |
| 2864 | |
| 2865 | if (url_open_dyn_buf(&c->pb) < 0) { |
| 2866 | /* XXX: cannot do more */ |
| 2867 | c->pb = NULL; /* safety */ |
| 2868 | return -1; |
| 2869 | } |
| 2870 | |
| 2871 | /* check version name */ |
| 2872 | if (strcmp(protocol, "RTSP/1.0") != 0) { |
| 2873 | rtsp_reply_error(c, RTSP_STATUS_VERSION); |
| 2874 | goto the_end; |
| 2875 | } |
| 2876 | |
| 2877 | /* parse each header line */ |
| 2878 | memset(header, 0, sizeof(*header)); |
| 2879 | /* skip to next line */ |
| 2880 | while (*p != '\n' && *p != '\0') |
| 2881 | p++; |
| 2882 | if (*p == '\n') |
| 2883 | p++; |
| 2884 | while (*p != '\0') { |
| 2885 | p1 = memchr(p, '\n', (char *)c->buffer_ptr - p); |
| 2886 | if (!p1) |
| 2887 | break; |
| 2888 | p2 = p1; |
| 2889 | if (p2 > p && p2[-1] == '\r') |
| 2890 | p2--; |
| 2891 | /* skip empty line */ |
| 2892 | if (p2 == p) |
| 2893 | break; |
| 2894 | len = p2 - p; |
| 2895 | if (len > sizeof(line) - 1) |
| 2896 | len = sizeof(line) - 1; |
| 2897 | memcpy(line, p, len); |
| 2898 | line[len] = '\0'; |
| 2899 | ff_rtsp_parse_line(header, line, NULL); |
| 2900 | p = p1 + 1; |
| 2901 | } |
no test coverage detected