request an fcgi site [C]

hi leute!

ich habe folgendes problem:
ich möchte einen request an eine fcgi site senden!
der request in meinem programm sieht so aus:
GET /dieseite.fcgi?parameter=.... HTTP/1.1\nHost: 123.234.123.234\n\n

ich bekomme keine antwort vom server! also das programm wartet dann die ganze zeit darauf das es etwas empfängt nur bekommt es nichts zurück!

mfg
Frütschi
 
das dürfte aber keine fehler haben weil ich andere seiten damit abrufen kann nur eben nicht diese fcgi seite!
Code:
	#include <stdio.h>
	#include <errno.h>
	#include <string.h>
	#include <conio.h>

	#include <winsock.h>
	#include <io.h>

	#define HTTP_PORT 80

void main()
{
	int sock;
	struct sockaddr_in host_addr;
	struct hostent *hostinfo;
	char host[200], file[200];
	char command[3000];
	char buf[1024];
	unsigned int bytes_sent, bytes_recv;

	strcpy(host, "thehost.de");
	strcpy(file, "/asdf.fcgi?argument=123");

	WSADATA wsaData;
	if (WSAStartup (MAKEWORD(1, 1), &wsaData) != 0) {
		fprintf (stderr, "WSAStartup(): Kann Winsock nicht initialisieren.\n");
		getch();
		exit (EXIT_FAILURE);
	}
	sock = socket (AF_INET, SOCK_STREAM, 0);
	printf("sock");
	if (sock == -1) {
		perror ("socket()");
		getch();
		exit (EXIT_FAILURE);
	}
	memset( &host_addr, 0, sizeof (host_addr));
	host_addr.sin_family = AF_INET;
	host_addr.sin_port = htons (HTTP_PORT);
	host_addr.sin_addr.s_addr = inet_addr (host);
	if (host_addr.sin_addr.s_addr == INADDR_NONE) {
		hostinfo = gethostbyname (host);
	if (hostinfo == NULL) {
		perror ("gethostbyname()");
		getch();
	exit (EXIT_FAILURE);
	}
	memcpy((char*) &host_addr.sin_addr.s_addr, hostinfo->h_addr, hostinfo->h_length);
	}
	if (connect(sock, (struct sockaddr *) &host_addr, sizeof(struct sockaddr)) == -1) {
	perror ("connect()");
	getch();
	exit (EXIT_FAILURE);
	}
	printf("connect");
	sprintf (command, "GET %s HTTP/1.1\nHost: %s\n\n", file, host);
	bytes_sent = send (sock, command, strlen (command), 0);

	printf("send");
	if (bytes_sent == -1) {
		perror ("send()");
		getch();
		exit (EXIT_FAILURE);
	}
	while ((bytes_recv = recv (sock, buf, sizeof(buf), 0)) > 0) {
		write (1, buf, bytes_recv);
	}
	printf("recv");
	if (bytes_recv == -1) {
		perror ("recv()");
		getch();
		exit (EXIT_FAILURE);
	}
	printf ("\n");
	closesocket(sock);
	WSACleanup();
}
 
naja sieht nicht so aus weil ich hab jetzt die anfrage die firefox schickt gesnifft und sie 1:1 in mein programm übernommen und es funktioniert trotzdem nicht!

sprintf (command, "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\n\n", file, host);

ok kurz nach dem ich den vorherigen teil geschrieben habe habe ich folgendes gefunden:
ich hab zum schluss beim request \n\n gehabt aber da gehört: \r\n\r\n und jetzt funktionierts! das is aber n echt empfindlicher server wies aussieht!

thx leutz!
 
Zurück
Oben