- tmp = memchr(data, '\n', data_len);
- if (!tmp || tmp[-1] != '\r') {
- if (data_len < SILC_HTTP_SERVER_BUFLEN)
- return TRUE;
- return FALSE;
- }
- *tmp = 0;
-
- /* Get method */
- if (strchr(data, ' '))
- *strchr(data, ' ') = 0;
- method = data;
- SILC_LOG_DEBUG(("Method: '%s'", method));
-
- /* Get URI */
- tmp = memchr(data, '\0', data_len);
- if (!tmp) {
- if (data_len < SILC_HTTP_SERVER_BUFLEN)
- return TRUE;
- return FALSE;
- }
- tmp++;
- if (strchr(tmp, ' '))
- *strchr(tmp, ' ') = 0;
- uri = tmp;
- SILC_LOG_DEBUG(("URI: '%s'", uri));
-
- /* Get HTTP headers */
- tmp++;
- tmp = memchr(tmp, '\n', data_len - (tmp - data)) + 1;
- if (!tmp) {
- if (data_len < SILC_HTTP_SERVER_BUFLEN)
- return TRUE;
- return FALSE;
+ SILC_LOG_HEXDUMP(("HTTP data"), silc_buffer_data(conn->inbuf),
+ silc_buffer_len(conn->inbuf));
+
+ if (!conn->method && !conn->uri) {
+ tmp = memchr(data, '\n', data_len);
+ if (!tmp || tmp[-1] != '\r') {
+ if (data_len < SILC_HTTP_SERVER_BUFLEN)
+ return TRUE;
+ return FALSE;
+ }
+ *tmp = 0;
+
+ /* Get method */
+ if (strchr(data, ' '))
+ *strchr(data, ' ') = 0;
+ conn->method = data;
+ SILC_LOG_DEBUG(("Method: '%s'", conn->method));
+
+ /* Get URI */
+ tmp = memchr(data, '\0', data_len);
+ if (!tmp) {
+ if (data_len < SILC_HTTP_SERVER_BUFLEN)
+ return TRUE;
+ return FALSE;
+ }
+ tmp++;
+ if (strchr(tmp, ' '))
+ *strchr(tmp, ' ') = 0;
+ conn->uri = tmp;
+ SILC_LOG_DEBUG(("URI: '%s'", conn->uri));
+
+ /* Protocol version compatibility */
+ tmp = memchr(tmp, '\0', data_len - (tmp - data)) + 1;
+ SILC_LOG_DEBUG(("Protocol: %s", tmp));
+ if (strstr(tmp, "HTTP/1.0"))
+ conn->keepalive = FALSE;
+ if (strstr(tmp, "HTTP/1.1"))
+ conn->keepalive = TRUE;
+ if (strstr(tmp, "HTTP/1.2"))
+ conn->keepalive = TRUE;
+
+ /* Get HTTP headers */
+ tmp = memchr(tmp, '\0', data_len - (tmp - data));
+ if (!tmp) {
+ if (data_len < SILC_HTTP_SERVER_BUFLEN)
+ return TRUE;
+ return FALSE;
+ }
+ if (data_len - (tmp - data) < 2) {
+ if (data_len < SILC_HTTP_SERVER_BUFLEN)
+ return TRUE;
+ return FALSE;
+ }
+ conn->hptr = ++tmp;