X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/546b7396244452dba8f9cb917e904028ab01dda5..fb6ea8dca0129dbb93ecb5fe1147a7b03138bbf8:/sbr/oauth.c diff --git a/sbr/oauth.c b/sbr/oauth.c old mode 100644 new mode 100755 index 85fe7146..0cc95e4e --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -26,13 +26,13 @@ #define JSON_TYPE "application/json" -/* We pretend access tokens expire 30 seconds earlier than they actually do to +/* We pretend access tokens expire 60 seconds earlier than they actually do to * allow for separate processes to use and refresh access tokens. The process * that uses the access token (post) has an error if the token is expired; the * process that refreshes the access token (send) must have already refreshed if * the expiration is close. * - * 30s is arbitrary, and hopefully is enough to allow for clock skew. + * 60s is arbitrary, and hopefully is enough to allow for clock skew. * Currently only Gmail supports XOAUTH2, and seems to always use a token * life-time of 3600s, but that is not guaranteed. It is possible for Gmail to * issue an access token with a life-time so short that even after send @@ -44,7 +44,7 @@ * (not counting header and not null-terminated) */ #define RESPONSE_BODY_MAX 8192 -/* Maxium size for URLs and URI-encoded query strings, null-terminated. +/* Maximum size for URLs and URI-encoded query strings, null-terminated. * * Actual maximum we need is based on the size of tokens (limited by * RESPONSE_BODY_MAX), code user copies from a web page (arbitrarily large), and @@ -956,6 +956,14 @@ post(struct curl_ctx *ctx, const char *url, const char *req_body) curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, ctx); + if (strncmp(url, "http://127.0.0.1:", 17) == 0) { + /* Hack: on Cygwin, curl doesn't fail to connect with ECONNREFUSED. + Instead, it waits to timeout. So set a really short timeout, but + just on localhost (for convenience of the user, and the test + suite). */ + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2L); + } + status = curl_easy_perform(curl); /* first check for error from callback */ if (ctx->too_big) {