Flush after printf(). Added user-agent. Add cond (want_read and want_write) to event-loop
This commit is contained in:
parent
31aff01697
commit
5fdadc4806
|
@ -153,6 +153,7 @@ public:
|
||||||
"method", "GET",
|
"method", "GET",
|
||||||
"scheme", "https",
|
"scheme", "https",
|
||||||
"url", path,
|
"url", path,
|
||||||
|
"user-agent", "spdylay/0.0.0",
|
||||||
"version", "HTTP/1.1",
|
"version", "HTTP/1.1",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -237,6 +238,7 @@ void on_ctrl_recv_callback
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_data_chunk_recv_callback
|
void on_data_chunk_recv_callback
|
||||||
|
@ -250,6 +252,10 @@ void on_data_recv_callback
|
||||||
{
|
{
|
||||||
printf("recv DATA frame (stream_id=%d, flags=%d, length=%d)\n",
|
printf("recv DATA frame (stream_id=%d, flags=%d, length=%d)\n",
|
||||||
stream_id, flags, length);
|
stream_id, flags, length);
|
||||||
|
if(flags & SPDYLAY_FLAG_FIN) {
|
||||||
|
spdylay_submit_goaway(session);
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_ctrl_send_callback
|
void on_ctrl_send_callback
|
||||||
|
@ -264,9 +270,12 @@ void on_ctrl_send_callback
|
||||||
frame->syn_stream.hd.length);
|
frame->syn_stream.hd.length);
|
||||||
print_nv(frame->syn_stream.nv);
|
print_nv(frame->syn_stream.nv);
|
||||||
break;
|
break;
|
||||||
|
case SPDYLAY_GOAWAY:
|
||||||
|
printf("(last_good_stream_id=%d)\n", frame->goaway.last_good_stream_id);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctl_epollev(int epollfd, int op, SpdylayClient& sc)
|
void ctl_epollev(int epollfd, int op, SpdylayClient& sc)
|
||||||
|
@ -372,7 +381,7 @@ int communicate(const char *host, const char *service, const char *path,
|
||||||
static const size_t MAX_EVENTS = 1;
|
static const size_t MAX_EVENTS = 1;
|
||||||
epoll_event events[MAX_EVENTS];
|
epoll_event events[MAX_EVENTS];
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
while(1) {
|
while(sc.want_read() || sc.want_write()) {
|
||||||
int nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);
|
int nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);
|
||||||
if(nfds == -1) {
|
if(nfds == -1) {
|
||||||
perror("epoll_wait");
|
perror("epoll_wait");
|
||||||
|
|
Loading…
Reference in New Issue