Skip to content

Commit

Permalink
Write initial auth GET request in non-blocking mode
Browse files Browse the repository at this point in the history
Now we can remain non-blocking all the way to fetching the body.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 12, 2012
1 parent 409dfab commit 1a39aef
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions http.c
Expand Up @@ -244,6 +244,9 @@ static int process_http_response(struct openconnect_info *vpninfo, int *result,
bodylen==BODY_CHUNKED?"chunked" : "length: ",
bodylen);

/* We don't cope with nonblocking mode... yet */
fcntl(vpninfo->ssl_fd, F_SETFL, fcntl(vpninfo->ssl_fd, F_GETFL) & ~O_NONBLOCK);

/* If we were given Content-Length, it's nice and easy... */
if (bodylen > 0) {
body = malloc(bodylen + 1);
Expand Down Expand Up @@ -640,9 +643,6 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
return -EINVAL;
}

/* We don't cope with nonblocking mode... yet */
fcntl(vpninfo->ssl_fd, F_SETFL, fcntl(vpninfo->ssl_fd, F_GETFL) & ~O_NONBLOCK);

/*
* It would be nice to use cURL for this, but we really need to guarantee
* that we'll be using OpenSSL (for the TPM stuff), and it doesn't seem
Expand Down Expand Up @@ -683,7 +683,9 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
method, vpninfo->hostname, vpninfo->port,
vpninfo->urlpath ?: "");

SSL_write(vpninfo->https_ssl, buf, strlen(buf));
result = openconnect_SSL_write(vpninfo, buf, strlen(buf));
if (result < 0)
return result;

buflen = process_http_response(vpninfo, &result, NULL, &form_buf);
if (buflen < 0) {
Expand Down

0 comments on commit 1a39aef

Please sign in to comment.