Rename http_header_complete() to is_http_header_complete()

This commit is contained in:
Andrew Bettison 2013-10-16 11:22:02 +10:30
parent 609e47faba
commit 00cf61721d
5 changed files with 7 additions and 7 deletions

View File

@ -269,7 +269,7 @@ int rhizome_str_is_bundle_crypt_key(const char *text);
int rhizome_strn_is_file_hash(const char *text);
int rhizome_str_is_file_hash(const char *text);
int http_header_complete(const char *buf, size_t len, size_t read_since_last_call);
int is_http_header_complete(const char *buf, size_t len, size_t read_since_last_call);
typedef struct sqlite_retry_state {
unsigned int limit; // do not retry once elapsed >= limit

View File

@ -688,7 +688,7 @@ static int receive_http_response(int sock, char *buffer, size_t buffer_len, stru
if ((count = read(sock, &buffer[len], buffer_len - len)) == -1)
return WHYF_perror("read(%d, %p, %d)", sock, &buffer[len], (int)buffer_len - len);
len += count;
} while (len < buffer_len && count != 0 && !http_header_complete(buffer, len, len));
} while (len < buffer_len && count != 0 && !is_http_header_complete(buffer, len, len));
if (config.debug.rhizome_rx)
DEBUGF("Received HTTP response %s", alloca_toprint(-1, buffer, len));
if (unpack_http_response(buffer, parts) == -1)

View File

@ -1483,7 +1483,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
slot->alarm.deadline = slot->alarm.alarm + config.rhizome.idle_timeout;
schedule(&slot->alarm);
slot->request_len += bytes;
if (http_header_complete(slot->request, slot->request_len, bytes)) {
if (is_http_header_complete(slot->request, slot->request_len, bytes)) {
if (config.debug.rhizome_rx)
DEBUGF("Got HTTP reply: %s", alloca_toprint(160, slot->request, slot->request_len));
/* We have all the reply headers, so parse them, taking care of any following bytes of
@ -1564,7 +1564,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
This function takes a pointer to a buffer into which the entire HTTP response header has been
read. The caller must have ensured that the buffer contains at least one consecutive pair of
newlines '\n', optionally with carriage returns '\r' preceding and optionally interspersed with
nul characters '\0' (which can originate from telnet). The http_header_complete() function
nul characters '\0' (which can originate from telnet). The is_http_header_complete() function
is useful for this.
This returns pointers to within the supplied buffer, and may overwrite some characters in the
buffer, for example to nul-terminate a string that was terminated by space ' ' or newline '\r'

View File

@ -232,7 +232,7 @@ void rhizome_client_poll(struct sched_ent *alarm)
unschedule(&r->alarm);
schedule(&r->alarm);
r->request_length += bytes;
r->header_length = http_header_complete(r->request, r->request_length, bytes);
r->header_length = is_http_header_complete(r->request, r->request_length, bytes);
if (r->header_length){
/* We have the request. Now parse it to see if we can respond to it */
if (rhizome_http_parse_func!=NULL)
@ -334,7 +334,7 @@ int rhizome_server_free_http_request(rhizome_http_request *r)
return 0;
}
int http_header_complete(const char *buf, size_t len, size_t read_since_last_call)
int is_http_header_complete(const char *buf, size_t len, size_t read_since_last_call)
{
IN();
const char *bufend = buf + len;

2
str.h
View File

@ -148,7 +148,7 @@ __STR_INLINE ssize_t str_rindex(const char *s, char c)
* nul-terminated, but are held in a buffer which has an associated length. To avoid this function
* running past the end of the buffer, the caller must ensure that the buffer contains a sub-string
* that is not part of the sub-string being sought, eg, "\r\n\r\n" as detected by
* http_header_complete(). This guarantees that this function will return nonzero before running
* is_http_header_complete(). This guarantees that this function will return nonzero before running
* past the end of the buffer.
*
* @author Andrew Bettison <andrew@servalproject.com>