summaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 3692ed4d08..af1b67e091 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -2022,6 +2022,31 @@ parse_socks_client(const uint8_t *data, size_t datalen,
return -1;
}
+/** Return true if <b>cmd</b> looks like a HTTP (proxy) request. */
+int
+peek_buf_has_http_command(buf_t *buf)
+{
+ if (peek_buf_startswith(buf, "CONNECT ") ||
+ peek_buf_startswith(buf, "DELETE ") ||
+ peek_buf_startswith(buf, "GET ") ||
+ peek_buf_startswith(buf, "POST ") ||
+ peek_buf_startswith(buf, "PUT " ))
+ return 1;
+ return 0;
+}
+
+/** Return 1 iff <b>buf</b> starts with <b>cmd</b>. <b>cmd</b> must be a null
+ * terminated string */
+int
+peek_buf_startswith(buf_t *buf, const char *cmd)
+{
+ int clen = strlen(cmd);
+ if (buf->datalen >= clen)
+ if (!strncasecmp((buf->head)->data, cmd, (size_t) clen))
+ return 1;
+ return 0;
+}
+
/** Return 1 iff buf looks more like it has an (obsolete) v0 controller
* command on it than any valid v1 controller command. */
int