summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/ubrowser/httpfactory.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/net/ubrowser/httpfactory.cpp b/noncore/net/ubrowser/httpfactory.cpp
index 4ace4cb..b37e9f9 100644
--- a/noncore/net/ubrowser/httpfactory.cpp
+++ b/noncore/net/ubrowser/httpfactory.cpp
@@ -202,68 +202,74 @@ const QByteArray HttpFactory::processResponse( int sockfd, bool &isText ) const
202 if( *(inputBin.data()) == '\n' ) 202 if( *(inputBin.data()) == '\n' )
203 { 203 {
204 if( currentLine.isEmpty() || currentLine.startsWith( "\r") ) 204 if( currentLine.isEmpty() || currentLine.startsWith( "\r") )
205 { 205 {
206 printf( "HttpFactory::processResponse: end of header\n" ); 206 printf( "HttpFactory::processResponse: end of header\n" );
207 if( chunked ) 207 if( chunked )
208 { 208 {
209 return recieveChunked( sockfd ); 209 return recieveChunked( sockfd );
210 } else { 210 } else {
211 return recieveNormal( sockfd, dataLength ); 211 return recieveNormal( sockfd, dataLength );
212 } 212 }
213 done = true; 213 done = true;
214 } 214 }
215 215
216 if( currentLine.contains( "Transfer-Encoding: chunked", false) >= 1 ) 216 if( currentLine.contains( "Transfer-Encoding: chunked", false) >= 1 )
217 { 217 {
218 chunked = true; 218 chunked = true;
219 printf( "HttpFactory::processResponse: chunked encoding\n" ); 219 printf( "HttpFactory::processResponse: chunked encoding\n" );
220 } 220 }
221 221
222 if( currentLine.contains( "Content-Type: text", false ) >= 1 ) 222 if( currentLine.contains( "Content-Type: text", false ) >= 1 )
223 { 223 {
224 isText = true; 224 isText = true;
225 printf( "HttpFactory::processResponse: content type text\n" ); 225 printf( "HttpFactory::processResponse: content type text\n" );
226 if( currentLine.contains( "html", false ) ) 226 if( currentLine.contains( "html", false ) >= 1)
227 { 227 {
228 browser->setTextFormat(Qt::RichText); 228 browser->setTextFormat(Qt::RichText);
229 printf( "HttpFactory::processResponse: content type html\n" ); 229 printf( "HttpFactory::processResponse: content type html\n" );
230 } 230 }
231 } 231 }
232 232
233 if( currentLine.contains( "Content-Type: image", false ) >= 1 ) 233 if( currentLine.contains( "Content-Type: image", false ) >= 1 )
234 { 234 {
235 isText = false; 235 isText = false;
236 printf( "HttpFactory::processResponse: content type image\n" ); 236 printf( "HttpFactory::processResponse: content type image\n" );
237 } 237 }
238 238
239 if( currentLine.contains( "Content-Length", false ) >= 1 ) 239 if( currentLine.contains( "Content-Length", false ) >= 1 )
240 { 240 {
241 currentLine.remove( 0, 16 ); 241 currentLine.remove( 0, 16 );
242 dataLength = currentLine.toInt(); 242 dataLength = currentLine.toInt();
243 printf( "HttpFactory::processResponse: content length: %d\n", dataLength ); 243 printf( "HttpFactory::processResponse: content length: %d\n", dataLength );
244 } 244 }
245 245
246 if( currentLine.contains( "404", false ) >= 1 )
247 {
248 printf( "HttpFactory::processResponse: 404 error\n" );
249 return 0;
250 }
251
246 currentLine = ""; 252 currentLine = "";
247 printf("HttpFactory::processResponse: reseting currentLine: %s\n", currentLine.latin1() ); 253 printf("HttpFactory::processResponse: reseting currentLine: %s\n", currentLine.latin1() );
248 } 254 }
249 } 255 }
250} 256}
251 257
252const QByteArray HttpFactory::recieveNormal( int sockfd, int dataLen ) const 258const QByteArray HttpFactory::recieveNormal( int sockfd, int dataLen ) const
253{ 259{
254 printf( "HttpFactory::recieveNormal: recieving w/out chunked encoding\n" ); 260 printf( "HttpFactory::recieveNormal: recieving w/out chunked encoding\n" );
255 261
256 QByteArray data( dataLen ); 262 QByteArray data( dataLen );
257 QByteArray temp( dataLen ); 263 QByteArray temp( dataLen );
258 int recieved, i; 264 int recieved, i;
259 265
260 recieved = recv( sockfd, temp.data(), temp.size(), 0 ); 266 recieved = recv( sockfd, temp.data(), temp.size(), 0 );
261 printf( "HttpFactory::recieveNormal: found some data: %s\n", (char *)temp.data() ); 267 printf( "HttpFactory::recieveNormal: found some data: %s\n", (char *)temp.data() );
262 for( i = 0; i < recieved; i++ ) 268 for( i = 0; i < recieved; i++ )
263 { 269 {
264 data[i] = temp[i]; 270 data[i] = temp[i];
265 } 271 }
266 dataLen -= recieved; 272 dataLen -= recieved;
267 while( dataLen > 0 ) 273 while( dataLen > 0 )
268 { 274 {
269 recieved = recv( sockfd, temp.data(), temp.size(), 0 ); 275 recieved = recv( sockfd, temp.data(), temp.size(), 0 );