Обсуждение: CGI error
I'm getting this when access the cgi: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: Here's the cgi code: int main() { printf("Content-Type: %s\n\n", contentType); conn = PQconnectdb("dbname=template1"); if (PQstatus(conn) == CONNECTION_BAD) { printf("Connection to database failed.\n"); printf("%s", PQerrorMessage(conn)); return(1); } strcpy(query_string, "SELECT * FROM cities"); res = PQexec(conn, query_string); if (PQresultStatus(res) != PGRES_TUPLES_OK) { printf("SELECT query failed.\n"); PQclear(res); PQfinish(conn); return(1); } for (i = 0; i < PQntuples(res); i++) printf("%s\n", PQgetvalue(res, i, 0)); PQclear(res); PQfinish(conn); return(0); }
On Thu, Feb 22, 2001 at 07:52:54PM -0500, Jeff wrote: > I'm getting this when access the cgi: What HTTP daemon are you using? > The specified CGI application misbehaved by not returning a complete set of > HTTP headers. The headers it did return are: Which headers did it return? You seem to have forgotten to paste something. > printf("Content-Type: %s\n\n", contentType); The HTTP standard specifies that lines should be ended by a CRLF pair - i.e. "\r\n". Usually your HTTP daemon is smart enough to correct it (or the browser does), but maybe that's the problem. This doesn't seem related to Postgres. Try getting a simple CGI script to work (i.e. printing "hello world") -- the same problem should occur, AFAICT. HTH, Neil -- Neil Conway <neilconway@home.com> Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc Encrypted mail welcomed If one really is a superior person, the fact is likely to leak out without too much assistance. -- John Andrew Homes