Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo, ich habe da dieses eine Problem. Ich versuche seit einigen Tagen mich mit Perl Testing auseinander zu setzen. Eine mir gestellte Aufgabe war es einen einfach Webserver testen.

Kann mir jemand einen Tipp geben bzw. helfen ?

Danke.

Webserver Quellcode:

#!c:\Perl\bin\perl.exe

#package server;

use strict;

use Socket;

use IO::Socket;

our $port; #server port

our $content; #content type

our $server; #server

our $client; #server accept

our %req = (); #request results

our %data = (); #method and status data

our $root_folder = 'c:\perlscripts\public_html'; #root http folder

server(); #start server

client(); #start client

sub server {

$port = 5555;

$server = IO::Socket::INET->new ( Proto => 'tcp',

LocalPort => $port,

Listen => SOMAXCONN,

Reuse => 1);

$server or die "Unable to create server socket: $!";

print ("\nserver created, port: " . $port . "\n\n");

} #sub server end

sub client {

while ($client = $server->accept()) {

$client->autoflush(1);

$/ = Socket::CRLF;

while (<$client>) {

chomp;

print STDERR ;

if (/^\s*(\w+)\s*([^\s]+)\s*HTTP\/(\d.\d)/) {

$req{method} = $1;

($req{url} = $2) =~ tr/^\//\\/;

$req{httpv} = $3;

} elsif (/^$/) {

last;

}

}

if ( defined ($req{method}) && defined ($req{url}) && defined ($req{httpv}) ) {

unless ($req{url} =~ /\.\./) {

if ($req{url} =~ /.html$/i) {

$content = "text/html";

} elsif ($req{url} =~ /.jpg$/i) {

$content = "image/jpg";

} elsif ($req{url} =~ /.jpeg$/i){

$content = "image/jpeg";

} elsif ($req{url} =~ /.gif$/i) {

$content = "image/gif";

}

if ($req{method} eq "GET" or $req{method} eq "POST") {

$data{method} = $req{method};

} else {

print STDERR ("\nno request method found");

$data{method} = "ERROR";

last;

}

print $client "HTTP/1.0 200 OK", Socket::CRLF;

print $client "Content-type: $content", Socket::CRLF;

print $client Socket::CRLF;

print $client "<HTML>

<HEAD>

<Title>einfache Testseite</Title>

<H1>Meine erste Webseite!</H1>

<H5>Diese ist so einfach,<H5>

<H6>da braucht man garnicht hinsehen.</H6>

</HEAD>

<BODY>

</BODY>

</HTML>";

$data{stat} = "202";

close(FILE);

} else {

print $client "HTTP/1.0 404 Not Found", Socket::CRLF;

print $client Socket::CRLF;

print $client "<HTML>

<HEAD>

<H5>Datei kann nicht geöffnet werden</H5>

</HEAD>

<BODY>

404 Not Found

</BODY>

</HTML>";

$data{method} = "ERROR";

$data{stat} = "404";

} ### unless loop end

} else {

$data{method} = "ERROR";

$data{stat} = "404";

} ### if-defined loop end

print("\n" . $root_folder . $req{url} . "\n");

foreach my $key (keys(%data)) {

print("$key = $data{$key}\n");

}

close $client;

print STDERR ("\n");

} ### while client loop end

} #sub client end

#####EOF#####

Also im Moment wird einfach nur eine extrem Simple Seite ausgegeben.

Ich möchte während der Server läuft einen Test laufen lassen der:

1. die Variablen ausliest und auf Richtigkeit überprüft

2. wenn 1. funktioniert, dann einen Header an den Server senden und dessen Antwort überprüfen.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.