TOP
SSV Software Systems Register  Register
Log in to check your private messages  Log in to check your private messages
Startseite FAQ Search Mitglieder Profile  Log in 
SSV Support-Forum
Probleme mit Webserver …

 
Post new topic   Reply to topic    SSV-Forum Forum Index >>> DNP/9200
<<< Previous topic - Next topic >>>  
Display posts from previous:   
Author Message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 24.06.2010, 11:30    Post subject: Probleme mit Webserver … Reply with quote

Hallo Forum.

Vor kurzem erreichte uns eine Support-Anfrage hinsichtlich eines CGI-Programms. Der hier folgenden C-Quellcode wurde mit dem GNU C Compiler für den DNP/9200 übersetzt und im CGI-Verzeichnis des Webservers abgespeichert:

Code:
int main(int argc, char *argv[]) {
   printf("<html>\n");
   printf("<head>\n");
   printf("<title>Hallo-Welt-Titel</title>\n");
   printf("</head>\n");
   printf("<body>\n");
   printf("<h1>Hallo Welt</h1>\n");
   printf("</body>\n");
   printf("</html>\n");

   return EXIT_SUCCESS;
}

Die URL „http:/192.168.0.126/cgi-bin/programmname“ brachte beim IE das gewünschte Ergebnis – die HTML-Texte wurde also wie gewünscht von Browser dargestellt . Bei Firefox wurde hingegen eine leere Seite angezeigt.

In diesem Beispiel fehlt eine ganz wichtige Codezeile. Das Browser-unabhängige Beispiel muss wir folgt aussehen (siehe printf ("Content-type..."):

Code:
int main(int argc, char *argv[]) {
   printf("Content-type: text/html\n\n"); // <== !!!
   printf("<html>\n");
   printf("<head>\n");
   printf("<title>Hallo-Welt-Titel</title>\n");
   printf("</head>\n");
   printf("<body>\n");
   printf("<h1>Hallo Welt</h1>\n");
   printf("</body>\n");
   printf("</html>\n");

   return EXIT_SUCCESS;
}


Man muss in einem CGI-Programm auch den entsprechenden HTTP-Header erzeugen, aus dem der Browser erkennen kann, wie die folgenden Ausgaben (also die Texte im Message Body) dargestellt werden. Zwischen Header und Message sind zweimal „\n\n“ als Trennung erforderlich.

Gruß

KDW
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> DNP/9200 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

SSV Software Systems GmbH

Dünenweg 5
30419 Hannover

Fon: +49(0)511  ·  40 000-0
Fax: +49(0)511  ·  40 000-40

sales@ssv-embedded.de


Impressum    ·    Datenschutz    ·    AGB

© 2023 SSV SOFTWARE SYSTEMS GmbH. Alle Rechte vorbehalten.

ISO 9001:2015