Skip to content

Instantly share code, notes, and snippets.

@roxlu

roxlu/from.c Secret

Created April 5, 2014 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/60e4d0d297680e463389 to your computer and use it in GitHub Desktop.
Save roxlu/60e4d0d297680e463389 to your computer and use it in GitHub Desktop.
static void krx_https_conn_read(uv_stream_t* stream, ssize_t nbytes, uv_buf_t buf) {
krx_https_conn* c = (krx_https_conn*)stream->data;
if(!c) {
printf("Error: krx_https_conn_read(), user pointer not set.\n");
exit(1);
}
/* disconnected or other error. */
if(nbytes < 0) {
free(buf.base);
printf("- krx_https_conn_read(), %p, status: %s\n", c, uv_strerror(nbytes));
krx_https_close_connection(c);
return;
}
/* digest incoming data */
int written = BIO_write(c->in_bio, buf.base, nbytes);
if(written > 0) {
if(!SSL_is_init_finished(c->ssl)) {
int r = SSL_do_handshake(c->ssl);
if(r < 0) {
char buf[200];
int err = SSL_get_error(c->ssl, r);
char* d = ERR_error_string(err,buf);
}
krx_https_ssl_check_output_buffer(c);
}
else {
krx_https_ssl_check_input_buffer(c);
}
}
free(buf.base);
buf.base = NULL;
}
static void krx_https_conn_read(uv_stream_t* stream, ssize_t nbytes, uv_buf_t buf) {
krx_https_conn* c = (krx_https_conn*)stream->data;
if(!c) {
printf("Error: krx_https_conn_read(), user pointer not set.\n");
exit(1);
}
/* disconnected or other error. */
if(nbytes < 0) {
free(buf.base);
printf("- krx_https_conn_read(), %p, status: %s\n", c, uv_strerror(nbytes));
krx_https_close_connection(c);
return;
}
/* digest incoming data */
int written = BIO_write(c->in_bio, buf.base, nbytes);
if(written > 0) {
if(!SSL_is_init_finished(c->ssl)) {
int r = SSL_do_handshake(c->ssl);
if(r < 0) {
char buf[200];
int err = SSL_get_error(c->ssl, r);
char* d = ERR_error_string(err,buf);
}
krx_https_ssl_check_output_buffer(c);
}
}
krx_https_ssl_check_input_buffer(c);
free(buf.base);
buf.base = NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment