void Http::SendFile(char *path, struct stat *st) { const char *mime_type = GetMimeType(strrchr(path, '.')); SendHeader(mime_type, st->st_size, 200); if (strcmp(request.request_method, "HEAD") != 0) SendFileStream(path, st); }
bool SendFile( SOCKET sock, const char* strFileName, int nBufSize ) { //get file header NETF_STAT nfstat; if( GetNetfStat(strFileName, &nfstat)!=0 )return false; //send file header hton( nfstat ); SendNetfStat( sock, &nfstat ); //send the file content stream. FILE* pf = fopen( strFileName, "rb" ); if( pf==NULL )return false; bool bOk = SendFileStream( sock, pf, nBufSize ); fclose( pf ); return bOk; }