Listing 3. Writing the HTTP Request
request_len=strlen(REQUEST_TEMPLATE)+
strlen(host)+6;
if(!(request=(char *)malloc(request_len)))
err_exit("Couldn't allocate request");
sprintf(request,REQUEST_TEMPLATE,
host,port);
/* Find the exact request_len */
request_len=strlen(request);
r=SSL_write(ssl,request,request_len);
switch(SSL_get_error(ssl,r)){
case SSL_ERROR_NONE:
if(request_len!=r)
err_exit("Incomplete write!");
break;
default:
berr_exit("SSL write problem");
}
Copyright © 1994 - 2018 Linux Journal. All rights reserved.