X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fcgilib;a=blobdiff_plain;f=cgi.c;h=1f6b6a38575f220ba7997b026ff7dc4566672fab;hp=ad555c268344f2938c2d35f90c6f30e2035d6847;hb=d4402aecd61143979b686107f561dd28a5a67d09;hpb=75db2910edc7279c482ed77f3a9033de858220d9 diff --git a/cgi.c b/cgi.c index ad555c2..1f6b6a3 100644 --- a/cgi.c +++ b/cgi.c @@ -69,6 +69,7 @@ int cgiSetHeader (const char *name, const char *value) memset(pivot, 0, (cp-name + vp-value + 5) * sizeof (char)); strncpy (pivot, name, cp-name); + pivot[cp-name] = '\0'; strncat (pivot, ": ", 2); strncat (pivot, value, vp-value); strncat (pivot, "\r\n", 2); @@ -100,11 +101,19 @@ int cgiSetType (const char *type) void cgiHeader () { if (cgiType) + { printf ("Content-type: %s\r\n", cgiType); + free(cgiType); + cgiType = NULL; + } else printf ("Content-type: text/html\r\n"); if (cgiHeaderString) + { printf ("%s", cgiHeaderString); + free(cgiHeaderString); + cgiHeaderString = NULL; + } printf ("\r\n"); }