Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0c75bd00

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 0c75bd00cf14a04c9e750c58f289d8688cb579cc
  • Vorgänger dc3cd296
  • Nachfolger 7b2d21f4

Das Erzeugen der HTTP-Antwort in eine eigene Funktion ausgelagert, damit sie auch von anderer Stelle aus benutzt werden kann.

Unterschiede anzeigen:

SL/Form.pm
481 481
  $main::lxdebug->leave_sub();
482 482
}
483 483

  
484
sub create_http_response {
485
  $main::lxdebug->enter_sub();
486

  
487
  my $self     = shift;
488
  my %params   = @_;
489

  
490
  my $cgi      = $main::cgi;
491
  $cgi       ||= CGI->new('');
492

  
493
  my $base_path;
494

  
495
  if ($ENV{HTTP_X_FORWARDED_FOR}) {
496
    $base_path =  $ENV{HTTP_REFERER};
497
    $base_path =~ s|^.*?://.*?/|/|;
498
  } else {
499
    $base_path =  $ENV{REQUEST_URI};
500
  }
501
  $base_path =~ s|[^/]+$||;
502
  $base_path =~ s|/$||;
503

  
504
  my $session_cookie;
505
  if (defined $main::auth) {
506
    my $session_cookie_value   = $main::auth->get_session_id();
507
    $session_cookie_value    ||= 'NO_SESSION';
508

  
509
    $session_cookie = $cgi->cookie('-name'  => $main::auth->get_session_cookie_name(),
510
                                   '-value' => $session_cookie_value,
511
                                   '-path'  => $base_path);
512
  }
513

  
514
  my %cgi_params = ('-type' => $params{type});
515
  $cgi_params{'-charset'} = $params{charset} if ($parmas{charset});
516

  
517
  my $output = $cgi->header('-cookie' => $session_cookie,
518
                            %cgi_params);
519

  
520
  $main::lxdebug->leave_sub();
521

  
522
  return $output;
523
}
524

  
525

  
484 526
sub header {
485 527
  $main::lxdebug->enter_sub();
486 528

  
......
491 533
    return;
492 534
  }
493 535

  
494
  my $cgi   = $main::cgi;
495
  $cgi    ||= CGI->new('');
496

  
497 536
  my ($stylesheet, $favicon);
498 537

  
499 538
  if ($ENV{HTTP_USER_AGENT}) {
......
555 594
      $ajax .= $item->show_javascript();
556 595
    }
557 596

  
558
    my $base_path;
559

  
560
    if ($ENV{HTTP_X_FORWARDED_FOR}) {
561
      $base_path =  $ENV{HTTP_REFERER};
562
      $base_path =~ s|^.*?://.*?/|/|;
563
    } else {
564
      $base_path =  $ENV{REQUEST_URI};
565
    }
566
    $base_path =~ s|[^/]+$||;
567
    $base_path =~ s|/$||;
568

  
569
    my $session_cookie;
570
    if (defined $main::auth) {
571
      my $session_cookie_value   = $main::auth->get_session_id();
572
      $session_cookie_value    ||= 'NO_SESSION';
573

  
574
      $session_cookie = $cgi->cookie('-name'  => $main::auth->get_session_cookie_name(),
575
                                     '-value' => $session_cookie_value,
576
                                     '-path'  => $base_path);
577
    }
578

  
579
    print $cgi->header('-type'    => 'text/html',
580
                       '-charset' => $db_charset,
581
                       '-cookie'  => $session_cookie);
597
    print $self->create_http_response('type'    => 'text/html',
598
                                      'charset' => $db_charset,);
582 599
    print qq|${doctype}<html>
583 600
<head>
584 601
  <title>$self->{titlebar}</title>

Auch abrufbar als: Unified diff