summaryrefslogtreecommitdiff
path: root/src/or/proto_http.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-08-08 15:16:39 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-05 13:57:51 -0400
commit4a7e90adc5828263a5d2dc3744818f2189c04bc7 (patch)
tree62cac4a9acefb41d9e3b9b6ee7d6501ee64efc01 /src/or/proto_http.c
parent336aa21e37b6c5bd4f1215ceba27c21f6c43dce7 (diff)
downloadtor-4a7e90adc5828263a5d2dc3744818f2189c04bc7.tar.gz
tor-4a7e90adc5828263a5d2dc3744818f2189c04bc7.zip
Repair buffer API so everything starts with buf_.
Our convention is that functions which manipulate a type T should be named T_foo. But the buffer functions were super old, and followed all kinds of conventions. Now they're uniform. Here's the perl I used to do this: \#!/usr/bin/perl -w -i -p s/read_to_buf\(/buf_read_from_socket\(/; s/flush_buf\(/buf_flush_to_socket\(/; s/read_to_buf_tls\(/buf_read_from_tls\(/; s/flush_buf_tls\(/buf_flush_to_tls\(/; s/write_to_buf\(/buf_add\(/; s/write_to_buf_compress\(/buf_add_compress\(/; s/move_buf_to_buf\(/buf_move_to_buf\(/; s/peek_from_buf\(/buf_peek\(/; s/fetch_from_buf\(/buf_get_bytes\(/; s/fetch_from_buf_line\(/buf_get_line\(/; s/fetch_from_buf_line\(/buf_get_line\(/; s/buf_remove_from_front\(/buf_drain\(/; s/peek_buf_startswith\(/buf_peek_startswith\(/; s/assert_buf_ok\(/buf_assert_ok\(/;
Diffstat (limited to 'src/or/proto_http.c')
-rw-r--r--src/or/proto_http.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/or/proto_http.c b/src/or/proto_http.c
index 3977de1866..6e03165745 100644
--- a/src/or/proto_http.c
+++ b/src/or/proto_http.c
@@ -13,11 +13,11 @@
int
peek_buf_has_http_command(const 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 " ))
+ if (buf_peek_startswith(buf, "CONNECT ") ||
+ buf_peek_startswith(buf, "DELETE ") ||
+ buf_peek_startswith(buf, "GET ") ||
+ buf_peek_startswith(buf, "POST ") ||
+ buf_peek_startswith(buf, "PUT " ))
return 1;
return 0;
}
@@ -110,14 +110,14 @@ fetch_from_buf_http(buf_t *buf,
/* all happy. copy into the appropriate places, and return 1 */
if (headers_out) {
*headers_out = tor_malloc(headerlen+1);
- fetch_from_buf(*headers_out, headerlen, buf);
+ buf_get_bytes(*headers_out, headerlen, buf);
(*headers_out)[headerlen] = 0; /* NUL terminate it */
}
if (body_out) {
tor_assert(body_used);
*body_used = bodylen;
*body_out = tor_malloc(bodylen+1);
- fetch_from_buf(*body_out, bodylen, buf);
+ buf_get_bytes(*body_out, bodylen, buf);
(*body_out)[bodylen] = 0; /* NUL terminate it */
}
return 1;