Zum Inhalt springen

Empfohlene Beiträge

Geschrieben

Hi,

ich möchte gerne per PHP Script eine URL aufrufen, die per htaccess geschützt ist.

welche Header muss ich mitsenden, damit er benutzername und passwort sendet und ich zugriff bekomme?

Danke!

lg KuMpEl2

Geschrieben

Es will einfach nicht...

Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.


<?php
$server = 'host.com';
$request = 'GET /pfad/zum/script';
$tt = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n";
$tt1 = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n
Basic Authorization: Basic (korrekter code)";
$test = fsockopen($server,80);
fputs($test,$tt);
fputs($test,$tt1);
fputs($test,$request);
$result = '';
while(!feof($test))
{
$result .= fgets($test);
}
fclose($test);
echo $result;
?>
[/PHP]

Wenn ich mit HTTP/1.1 arbeite gibt er mir folgendes aus:

Bad Request

Your browser sent a request that this server could not understand.

client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /pfad/zum/script.cgi

Ich verzweifel bald... :(

Geschrieben
Ich verzweifel bald... :(
Dann sieh doch einfach mal die Fehlermeldung an, die du bekommen hast!

Die ist nicht nur da um belächelt zu werden sondern enthält in diesem Fall auch genau den Hinweis, den du brauchst: request without hostname.

HTTP/1.1 request without hostname (see RFC2616 section 14.23):
Und was steht in section 14.23?

The Host request-header field specifies the Internet host and port

number of the resource being requested, as obtained from the original

URI given by the user or referring resource (generally an HTTP URL,

as described in section 3.2.2). The Host field value MUST represent

the naming authority of the origin server or gateway given by the

original URL. This allows the origin server or gateway to

differentiate between internally-ambiguous URLs, such as the root "/"

URL of a server for multiple host names on a single IP address.

Host = "Host" ":" host [ ":" port ] ; Section 3.2.2

A "host" without any trailing port information implies the default

port for the service requested (e.g., "80" for an HTTP URL). For

example, a request on the origin server for

<http://www.w3.org/pub/WWW/> would properly include:

GET /pub/WWW/ HTTP/1.1

Host: www.w3.org

[...]

Also Host-Header mitsenden!

Geschrieben
Es will einfach nicht...


<?php
$server = 'host.com';
$request = 'GET /pfad/zum/script';
$tt = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n";
$tt1 = "
GET /nic/denic_stats.cgi HTTP/1.0\n
Accept: text/html, text/*; q=0.9\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6; Windows NT 6.0)\n
Connection: Keep-Alive\n
Basic Authorization: Basic (korrekter code)";
[/PHP]

HTTP 1.0 kennt m.w. keinen Host-header, nimm HTTP 1.1 und schick einen mit: "Host: www.denic.de"

wo ist dieser im obigen aufruf?

was ist "Basic Authorization: Basic"? das ist kein gültiger HTTP-header.

s'Amstel

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...