浏览代码

Some cleanup. Use names for some numeric constants.

master
Richard Nyberg 18 年前
父节点
当前提交
1d7b396fc7
共有 1 个文件被更改,包括 11 次插入13 次删除
  1. +11
    -13
      misc/http_client.c

+ 11
- 13
misc/http_client.c 查看文件

@@ -91,17 +91,21 @@ struct http_req {
enum {
HTTP_RESOLVE, HTTP_CONNECT, HTTP_WRITE, HTTP_RECEIVE, HTTP_PARSE
} state;
struct http_url *url;
enum {
PS_HEAD, PS_CHUNK_SIZE, PS_CHUNK_DATA, PS_CHUNK_CRLF, PS_ID_DATA
} pstate;

int sd;
struct event ev;
http_cb_t cb;
void *arg;
int cancel;

int pstate, chunked;
int chunked;
long length;

http_cb_t cb;
void *arg;

struct http_url *url;
struct evbuffer *buf;
struct event ev;
};

static void
@@ -128,12 +132,6 @@ http_error(struct http_req *req)
http_free(req);
}

#define PS_HEAD 0
#define PS_CHUNK_SIZE 1
#define PS_CHUNK_DATA 2
#define PS_CHUNK_CRLF 3
#define PS_ID_DATA 4

static int
headers_parse(struct http_req *req, char *buf, char *end)
{
@@ -391,7 +389,7 @@ http_dnscb(int result, char type, int count, int ttl, void *addrs, void *arg)
struct http_req *req = arg;
if (req->cancel)
http_free(req);
else if (result == 0 && type == 1 && count > 0) {
else if (result == DNS_ERR_NONE && type == DNS_IPv4_A && count > 0) {
int addri = rand_between(0, count - 1);
struct sockaddr_in addr;
addr.sin_family = AF_INET;


正在加载...
取消
保存