Fossil

Diff
Login

Differences From Artifact [0f74febdc6]:

To Artifact [a57c7b96ec]:


26
27
28
29
30
31
32



33
34
35
36
37
38
39
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







+
+
+







#ifndef isatty
#define isatty(d) _isatty(d)
#endif
#ifndef fileno
#define fileno(s) _fileno(s)
#endif
#endif

/* Maximum number of HTTP Authorization attempts */
#define MAX_HTTP_AUTH 2

/* Keep track of HTTP Basic Authorization failures */
static int fSeenHttpAuth = 0;

/*
** Construct the "login" card with the client credentials.
**
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291



292
293
294
295
296
297
298
299
300
301

302

303
304
305
306
307
308
309
277
278
279
280
281
282
283











284
285
286



287






288

289
290
291
292
293
294
295
296







-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-

-
-
-
-
-
-
+
-
+







  closeConnection = 1;
  iLength = -1;
  while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){
    /* printf("[%s]\n", zLine); fflush(stdout); */
    if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){
      if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
      if( rc==401 ){
        transport_close(GLOBAL_URL());
        if( --maxRedirect == 0 ){
          fossil_fatal("http authorization limit exceeded");
        }
        if( g.zHttpAuth==0 ){
          g.zHttpAuth = prompt_for_httpauth_creds();
        }
        if( g.zHttpAuth && g.zHttpAuth[0] ){
          if( fSeenHttpAuth ){
            free(g.zHttpAuth);
            g.zHttpAuth = 0;
        if( fSeenHttpAuth++ < MAX_HTTP_AUTH ){
          if( g.zHttpAuth ){
            if( g.zHttpAuth ) free(g.zHttpAuth);
            fSeenHttpAuth = 0;
          }else{
            fSeenHttpAuth = 1;
          }
          return http_exchange(pSend, pReply, useLogin, maxRedirect);
        }else{
          fossil_warning("HTTP Basic Authorization failed.");
          if( g.zHttpAuth ){
            free(g.zHttpAuth);
            g.zHttpAuth = 0;
          g.zHttpAuth = prompt_for_httpauth_creds();
          }
          transport_close(GLOBAL_URL());
          return http_exchange(pSend, pReply, useLogin, maxRedirect);
        }
      }
      if( rc!=200 && rc!=302 ){
        int ii;
        for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
        while( zLine[ii]==' ' ) ii++;