~squid/squid/sbuf-use

« back to all changes in this revision

Viewing changes to src/errorpage.cc

  • Committer: hno
  • Date: 2001-01-08 06:32:04 UTC
  • Revision ID: cvs-1:hno-20010108063204-w6a8e1zz6eprqnp8
Major rewrite of proxy authentication to support other schemes than
Basic (auth_rewrite branch on SourceForge).
Contributors:
   Andy Doran
   Robert Collins
   Chemolli Francesco
   Henrik Nordstrom

For details about the new API's, see Programmers Guide.

As part of this change everything from auth_modules has been moved to
src/auth/basic/helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
 * $Id: errorpage.cc,v 1.160 2001/01/05 09:51:37 adrian Exp $
 
3
 * $Id: errorpage.cc,v 1.161 2001/01/07 23:36:38 hno Exp $
4
4
 *
5
5
 * DEBUG: section 4     Error Generation
6
6
 * AUTHOR: Duane Wessels
52
52
 
53
53
/* local constant and vars */
54
54
 
55
 
static const char *const proxy_auth_challenge_fmt = "Basic realm=\"%s\"";
56
 
 
57
55
/*
58
56
 * note: hard coded error messages are not appended with %S automagically
59
57
 * to give you more control on the format
280
278
    storeBuffer(entry);
281
279
    rep = errorBuildReply(err);
282
280
    /* Add authentication header */
283
 
    switch (err->http_status) {
284
 
    case HTTP_PROXY_AUTHENTICATION_REQUIRED:
285
 
        /* Proxy authorisation needed */
286
 
        httpHeaderPutStrf(&rep->header, HDR_PROXY_AUTHENTICATE,
287
 
            proxy_auth_challenge_fmt, Config.proxyAuthRealm);
288
 
        break;
289
 
    case HTTP_UNAUTHORIZED:
290
 
        /* WWW Authorisation needed */
291
 
        httpHeaderPutStrf(&rep->header, HDR_WWW_AUTHENTICATE,
292
 
            proxy_auth_challenge_fmt, Config.proxyAuthRealm);
293
 
        break;
294
 
    default:
295
 
        /* Keep GCC happy */
296
 
        break;
297
 
    }
 
281
    /* TODO: alter errorstate to be accel on|off aware. The 0 on the next line
 
282
     * depends on authenticate behaviour: all schemes to date send no extra data
 
283
     * on 407/401 responses, and do not check the accel state on 401/407 responses 
 
284
     */
 
285
    authenticateFixHeader(rep, err->auth_user_request, err->request, 0);
298
286
    httpReplySwapOut(rep, entry);
299
 
    httpReplyDestroy(rep);
300
 
    mem->reply->sline.status = err->http_status;
301
 
    mem->reply->content_length = -1;
 
287
    httpReplyAbsorb(mem->reply, rep);
302
288
    EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
303
289
    storeBufferFlush(entry);
304
290
    storeComplete(entry);
361
347
    ErrorState *err = data;
362
348
    debug(4, 3) ("errorSendComplete: FD %d, size=%d\n", fd, size);
363
349
    if (errflag != COMM_ERR_CLOSING) {
364
 
        if (err->callback)
 
350
        if (err->callback) {
 
351
            debug(4, 3) ("errorSendComplete: callback\n");
365
352
            err->callback(fd, err->callback_data, size);
366
 
        else
 
353
        } else {
367
354
            comm_close(fd);
 
355
            debug(4, 3) ("errorSendComplete: comm_close\n");
 
356
        }
368
357
    }
369
358
    errorStateFree(err);
370
359
}
377
366
    safe_free(err->url);
378
367
    safe_free(err->host);
379
368
    safe_free(err->dnsserver_msg);
380
 
    safe_free(err->proxy_auth_msg);
381
369
    safe_free(err->request_hdrs);
382
370
    wordlistDestroy(&err->ftp.server_msg);
383
371
    safe_free(err->ftp.request);
384
372
    safe_free(err->ftp.reply);
 
373
    if (err->auth_user_request)
 
374
        authenticateAuthUserRequestUnlock(err->auth_user_request);
385
375
    cbdataFree(err);
386
376
}
387
377
 
483
473
            p = "[not available]";
484
474
        break;
485
475
    case 'm':
486
 
        p = err->proxy_auth_msg ? err->proxy_auth_msg : "[not available]";
 
476
        p = authenticateAuthUserRequestMessage(err->auth_user_request) ? authenticateAuthUserRequestMessage(err->auth_user_request) : "[not available]";
487
477
        break;
488
478
    case 'M':
489
479
        p = r ? RequestMethodStr[r->method] : "[unkown method]";