EmbedIT-WebIT

 view release on metacpan or  search on metacpan

lib/EmbedIT/WebIT.pm  view on Meta::CPAN

  }

  if ($conf->{'LOG_PACKETS'}) {
    &$logging("PACKET contents will be logged");
  } elsif ($conf->{'LOG_HEADERS'}) {
    &$logging("HEADERS will be logged");
  }

  if (defined $conf->{"DOCUMENTS"}) {
    if (defined $conf->{"DOCUMENT_ROOT"}) {
      &$logging("EMBEDED pages with EXTERNAL pages on (" . $conf->{"DOCUMENT_ROOT"} . ")");
    } else {
      &$logging("EMBEDED pages");
    }
  } else {
    &$logging("EXTERNAL pages on (" . $conf->{"DOCUMENT_ROOT"} . ")");
  }

  if (defined $conf->{"CGI_PATH"}) {
    if ($conf->{"EMBED_PERL"}) {
      &$logging("CGI pages on (" . $conf->{"CGI_PATH_PRINT"} . ") with PERL embeded");
    } else {
      &$logging("CGI pages on (" . $conf->{"CGI_PATH_PRINT"} . ")");
    }
  }

  if (defined $conf->{"AUTH_PATH"}) {
    if (not defined $conf->{"AUTH_METHOD"}) {
      &$logging("AUTHENTICATION will always fail");
    } else {

lib/EmbedIT/WebIT.pm  view on Meta::CPAN

    $ENV{"REMOTE_PORT"} = $rport;
    $ENV{"REMOTE_ADDR"} = $rhost;

    my $retval = undef;
    my $reterr = undef;

    my $type = '';

    if ($r->{METHOD} =~ /GET|HEAD|POST/o) {
      if ($script) {
        if (($conf->{"EMBED_PERL"} == 1) && ($path =~ /\.pl$/o)) {
          $type = 'PERL ';
          ($retval, $reterr, $page) = $self->__do_perl($id, $path, $r, $inauth_space);
          if (!$retval) {
            &$logging2("[$id] Script error ($reterr) on (" . $r->{URI} . ")");
            if ($err) {
              $page = $self->__make_error($reterr, $inauth_space, $id, $rhost, $rport, $r);
            }
          }
        } else {
          $type = 'CGI  ';
          ($retval, $reterr, $page) = $self->__do_cgi($id, $path, $r, $inauth_space);
          if (!$retval) {
            &$logging2("[$id] Script error ($reterr) on (" . $r->{URI} . ")");
            if ($err) {
              $page = $self->__make_error($reterr, $inauth_space, $id, $rhost, $rport, $r);
            }
          }
        }
      } elsif ($embed) {
        $type = 'EMBED';
        ($retval, $reterr, $page) = $self->__do_embeded($id, $path, $r, $inauth_space);
        if (!$retval) {
          &$logging2("[$id] Embeded function error ($reterr) on ($path)");
          if ($err) {
            $page = $self->__make_error($reterr, $inauth_space, $id, $rhost, $rport, $r);
          }
        }
      } else {
        $type = 'FILE ';
        ($retval, $reterr, $page) = $self->__do_file($path, $r, $inauth_space);

lib/EmbedIT/WebIT.pm  view on Meta::CPAN

  if (not defined $rconf->{"SOFTWARE"}) {
    $rconf->{"SOFTWARE"} = "WebIT/$VERSION";
  }
  if (not defined $rconf->{"SIGNATURE"}) {
    $rconf->{"SIGNATURE"} = "<br/>WebIT/$VERSION for Perl<br/>";
  }
  if (not defined $rconf->{"PROC_PREFIX"}) {
    $rconf->{"PROC_PREFIX"} = 'WebIT';
  }
  $rconf->{"PROC_PREFIX"} =~ s/\s\s/\s/go;
  if (not defined $rconf->{"EMBED_PERL"}) {
    $rconf->{"EMBED_PERL"} = 1;
  }
  if (not defined $rconf->{"QUEUE_SIZE"}) {
    $rconf->{"QUEUE_SIZE"} = 5;
  }
  if (defined $rconf->{"DOCUMENT_ROOT"}) {
    if ($rconf->{"DOCUMENT_ROOT"} !~ /\/$/) {
      $rconf->{"DOCUMENT_ROOT"} .= "/";
    }
  } else {
    $rconf->{"DOCUMENT_ROOT"} = undef;

lib/EmbedIT/WebIT.pm  view on Meta::CPAN


  if ($conf->{"SETUP_ENV"}) {
    $ENV{"SERVER_NAME"} = $conf->{"SERVER_NAME"};
    $ENV{"SERVER_PORT"} = $conf->{"SERVER_PORT"};
    $ENV{"SERVER_ADMIN"} = $conf->{"SERVER_ADMIN"};
    $ENV{"DOCUMENT_ROOT"} = $conf->{"DOCUMENT_ROOT"};
    $ENV{"SERVER_PROTOCOL"} = "HTTP/1.1";
    $ENV{"SERVER_SOFTWARE"} = $conf->{"SOFTWARE"};
    $ENV{"SERVER_SIGNATURE"} = $conf->{"SIGNATURE"};
    $ENV{"GATEWAY_INTERFACE"} = "CGI/1.1 WebIT for Perl";
    if ($conf->{"EMBED_PERL"}) {
      $ENV{"WEBIT_DATA"} = "INTERNAL";
    }
  }
  foreach my $k (keys %{$conf->{"ENV_ADD"}}) {
    $ENV{$k} = $conf->{"ENV_ADD"}->{$k};
  }
}

# --------------------------------------------------------------------------------------
# Fix environment variables for current request

lib/EmbedIT/WebIT.pm  view on Meta::CPAN


  $server = new EmbedIT::WebIT( SERVER_NAME   => 'www.my.org',
                                SERVER_IP     => '127.0.0.1',
                                SERVER_PORT   => 8080,
                                SOFTWARE      => 'MyApp web server',
                                QUEUE_SIZE    => 100,
                                RUN_AS_USER   => nobody,
                                RUN_AS_GROUP  => nogroup,
                                WAIT_RESPONSE => 1,
                                IMMED_CLOSE   => 1,
                                EMBED_PERL    => 1,
                                FORK_CONN     => 0,
                                SETUP_ENV     => 1,
                                SERVER_ADMIN  => 'info@my.org',
                                SERVERS       => 3,
                                WORKERS       => 1,
                                DOCUMENT_ROOT => '/opt/my/web',
                                DOCUMENTS     => {
                                                   '/index.html'    => 'WPages::index',
                                                   '/error.html'    => 'WPages::error',
                                                   '/style.css'     => 'WPages::style',

lib/EmbedIT/WebIT.pm  view on Meta::CPAN


=item ENV_ADD

Hash with environment variables and values to set for scripts. These environment variables and their values will be 
added to the environment of your CGI and embeded pages.

=item MIME_TYPES

Path and file where the server can find valid mimetypes. (default is /etc/mime.types)

=item EMBED_PERL

Run perl CGI scripts inside the server, not in a separate process. Faster than Apache and mod_perl. (default is 0)

=item SERVER_ADMIN

The email of the server administrator. This text will appear in the environment variables of the CGI / embeded pages (default is empty)

=item DOCUMENT_ROOT

The path where the site documents and scripts are stored. (default is undef)

soapdemo/test.pl  view on Meta::CPAN


# ----------------------------------------------------------------------------------------------------------

my $server = new EmbedIT::WebIT(  SERVER_NAME     => 'localhost',
                                  SERVER_IP       => '127.0.0.1',
                                  SERVER_PORT     => 8089,
                                  SOFTWARE        => 'MyApp',
                                  QUEUE_SIZE      => 100,
                                  WAIT_RESPONSE   => 1,
                                  IMMED_CLOSE     => 0,
                                  EMBED_PERL      => 1,
                                  FORK_CONN       => 1,
                                  SETUP_ENV       => 1,
                                  SERVER_ADMIN    => 'info@my.org',
                                  SERVERS         => 1,
                                  WORKERS         => 0,
                                  DOCUMENTS       => {
                                                       '/WS/Test' => 'main::WebServiceTest',
                                                     },
                                  ERROR_PAGES     => { 
                                                       'ALL' => '/error.html', 

webdemo/test.pl  view on Meta::CPAN


# ----------------------------------------------------------------------------------------------------------

my $server = new EmbedIT::WebIT(  SERVER_NAME     => 'localhost',
                                  SERVER_IP       => '127.0.0.1',
                                  SERVER_PORT     => 8089,
                                  SOFTWARE        => 'MyApp',
                                  QUEUE_SIZE      => 100,
                                  WAIT_RESPONSE   => 1,
                                  IMMED_CLOSE     => 0,
                                  EMBED_PERL      => 1,
                                  FORK_CONN       => 0,
                                  SETUP_ENV       => 1,
                                  SERVER_ADMIN    => 'info@my.org',
                                  SERVERS         => 1,
                                  WORKERS         => 0,
                                  DOCUMENT_ROOT   => 'test_site',
                                  DOCUMENTS       => {
                                                       '/index.html' => 'main::index_html',
                                                       '/error.html' => 'main::error_html',
                                                     },

webdemo/test_site/pod.html  view on Meta::CPAN

<pre>
  $server = new Embeded::WebIT( SERVER_NAME     =&gt; 'www.my.org',
                                SERVER_IP       =&gt; '127.0.0.1',
                                SERVER_PORT     =&gt; 8080,
                                SOFTWARE        =&gt; 'MyApp web server',
                                QUEUE_SIZE      =&gt; 100,
                                RUN_AS_USER     =&gt; nobody,
                                RUN_AS_GROUP    =&gt; nogroup,
                                WAIT_RESPONSE   =&gt; 1,
                                IMMED_CLOSE     =&gt; 1,
                                EMBED_PERL      =&gt; 1,
                                FORK_CONN       =&gt; 0,
                                SETUP_ENV       =&gt; 1,
                                SERVER_ADMIN    =&gt; 'info@my.org',
                                SERVERS         =&gt; 3,
                                WORKERS         =&gt; 1,
                                DOCUMENT_ROOT   =&gt; '/opt/my/web',
                                DOCUMENTS       =&gt; {
                                                     '/index.html'    =&gt; 'WPages::index',
                                                     '/error.html'    =&gt; 'WPages::error',
                                                     '/style.css'     =&gt; 'WPages::style',

webdemo/test_site/pod.html  view on Meta::CPAN


<dd>
<p>Hash with environment variables and values to set for scripts. These environment variables and their values will be 
added to the environment of your CGI and embeded pages.</p>
</dd>
<dt><strong><a name="mime_types" class="item">MIME_TYPES</a></strong></dt>

<dd>
<p>Path and file where the server can find valid mimetypes. (default is /etc/mime.types)</p>
</dd>
<dt><strong><a name="embed_perl" class="item">EMBED_PERL</a></strong></dt>

<dd>
<p>Run perl CGI scripts inside the server, not in a separate process. Faster than Apache and mod_perl. (default is 0)</p>
</dd>
<dt><strong><a name="server_admin" class="item">SERVER_ADMIN</a></strong></dt>

<dd>
<p>The email of the server administrator. This text will appear in the environment variables of the CGI / embeded pages (default is empty)</p>
</dd>
<dt><strong><a name="document_root" class="item">DOCUMENT_ROOT</a></strong></dt>



( run in 0.791 second using v1.01-cache-2.11-cpan-71847e10f99 )