3t3r4n Posted August 13, 2016 Report Posted August 13, 2016 (edited) Salut, nu inteleg de ce daca accesez in browser de pe acelasi PC o poza mi-o arata fara probleme iar daca incerc de pe alt PC din aceeasi retea nu se trimite tot fisierul si imi da eroare in browser ca fisier corupt. Fisierele html nu au probleme .. se intampla doar la imagini. if((extension=="png" or extension=="jpg" or extension=="gif") and pFile != NULL){ fclose (pFile); ifstream f(start_directory.append(uri).c_str(), ios::in|ios::binary|ios::ate); if(f.is_open()){ streampos size = f.tellg(); char* image = new char [size]; f.seekg (0, ios::beg); f.read (image, size); f.close(); header ="HTTP/1.0 200 OK\r\nExpires: 0\r\nPragma: no-cache\r\nPragma-directive: no-cache\r\nCache-control: no-cache\r\nCache-directive: no-cache\r\nContent-Type: image/"+extension+"\r\nServer: idev v0.05.8\r\n\r\n"; socket->sendStream(header.c_str(),header.size()); socket->sendStream(image,size); delete image; }else{ header="HTTP/1.0 401 Not Found\r\nConnection: close\r\n\r\n<h1>Bad Request (Invalid URL)</h1>"; socket->sendStream(header.c_str(),header.size()); } } EDIT: Cred ca problema e din fisierul Socket .. am schimbat cu mongoose si acelasi cod functioneaza cum trebuie Edited August 13, 2016 by 3t3r4n Quote
Sim Master Posted August 14, 2016 Report Posted August 14, 2016 Ar fi trebuit sa faci un print la headere si la continutul ce urmeaza sa fie trimis inapoi la client. Asa vedeai daca totul e ok, sau cel putin puteai compara un raspuns care mergea cu unul care nu mergea. 1 Quote