Skip to content

Instantly share code, notes, and snippets.

@roxlu roxlu/from.c Secret
Created Apr 5, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.