Ok so ive been writing code for a web server to return requested files, It works well for html and txt files but when an image is requested all i recieve is the url of the file... In firefox in conqueror i dont get anything. All i do is read the file and send it that is all so that part is fine. I think the problem is somewhere in the headers of the response of the server.
const char *r1="HTTP/1.1 200 OK\r\n";
const char *r2="Date: ";
const char *r3="\r\nConnection: close";
const char *r4="\r\nContent-Length: ";
const char *r5="\r\nContent-Type: ";
const char *r6="\r\n\r\n";
const char *r7="<Head><Title>Page Found</Title>";
const char *r8="<Body> File: ";
const char *r9=" was found</body></head>\r\n";
strcpy(returned,r1);
strcat(returned,r2);
strcat(returned,dates);
strcat(returned,r3);
strcat(returned,r4);
strcat(returned,ContentSize);
strcat(returned,r5);
strcat(returned,ContentType);
strcat(returned,r6);
if(isGet=0)
{
strcat(returned,r7);
strcat(returned,r8);
strcat(returned,FileName);
strcat(returned,r9);
}
if(isGet=1)
{
fin=open(pname,O_RDONLY);
frc = read(fin,bufferer,bufsiz);
strcat(returned,bufferer);
}
write(connsock,returned,strlen(returned));