summaryrefslogtreecommitdiff
path: root/noncore/net/ubrowser/httpcomm.cpp
authorspiralman <spiralman>2002-08-03 03:25:31 (UTC)
committer spiralman <spiralman>2002-08-03 03:25:31 (UTC)
commit7d4b246bc728b73e9d38e110619222dd89c1fd1c (patch) (unidiff)
tree7e6fbb8bbb106967993fa786a917fccde43970f3 /noncore/net/ubrowser/httpcomm.cpp
parent4005263f7c64a631f4df9aeece83321ba818160d (diff)
downloadopie-7d4b246bc728b73e9d38e110619222dd89c1fd1c.zip
opie-7d4b246bc728b73e9d38e110619222dd89c1fd1c.tar.gz
opie-7d4b246bc728b73e9d38e110619222dd89c1fd1c.tar.bz2
fixed relative links (except from forward and back buttons), added initial image code (not working), changes to chunked encoding (still not working, might be a qsocket issue)
Diffstat (limited to 'noncore/net/ubrowser/httpcomm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/ubrowser/httpcomm.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/noncore/net/ubrowser/httpcomm.cpp b/noncore/net/ubrowser/httpcomm.cpp
index 3c14053..4f189ce 100644
--- a/noncore/net/ubrowser/httpcomm.cpp
+++ b/noncore/net/ubrowser/httpcomm.cpp
@@ -39,12 +39,14 @@ void HttpComm::setUp(QString *newName)
39 name = newName; 39 name = newName;
40} 40}
41 41
42void HttpComm::setStuff(QString newHost, QString newPortS, QString newFile, QTextDrag *newText) 42void HttpComm::setStuff(QString newHost, QString newPortS, QString newFile, QTextDrag *newText, QImageDrag *newImage, bool newIsImage)
43{ 43{
44 host = newHost; 44 host = newHost;
45 portS = newPortS; 45 portS = newPortS;
46 file = newFile; 46 file = newFile;
47 text = newText; 47 text = newText;
48 isImage = newIsImage;
49 image = newImage;
48} 50}
49 51
50void HttpComm::hostFound() 52void HttpComm::hostFound()
@@ -70,12 +72,15 @@ void HttpComm::connected()
70 72
71void HttpComm::incoming() 73void HttpComm::incoming()
72{ 74{
73 int ba=socket->bytesAvailable(), i=0, j=0, semi=0; 75 int ba=socket->size(), i=0, j=0, semi=0;
74 char *tempString = new char [ba]; 76 char *tempString = new char [ba];
77 int br = socket->readBlock(tempString, ba);
78 socket->flush();
75 bool nextChunk=false; 79 bool nextChunk=false;
76 bool done=false; 80 bool done=false;
77 socket->readBlock(tempString, ba);
78 printf("HttpComm::incoming: ba: %d\n", ba); 81 printf("HttpComm::incoming: ba: %d\n", ba);
82 printf("HttpComm::incoming: bytes read from socket: %d\n", br);
83 //printf("HttpComm::incoming: tempString length: %d\n");
79 QString sclength; 84 QString sclength;
80 85
81 if(headerRead == false) 86 if(headerRead == false)
@@ -132,6 +137,7 @@ void HttpComm::incoming()
132 } 137 }
133 else 138 else
134 { 139 {
140 int startclength=0;
135 QString tempQString = tempString; 141 QString tempQString = tempString;
136 //remove the http header, if one exists 142 //remove the http header, if one exists
137 if(j != 0) 143 if(j != 0)
@@ -188,7 +194,10 @@ void HttpComm::incoming()
188 printf("%s", newTQstring.latin1() ); 194 printf("%s", newTQstring.latin1() );
189 printf("HttpComm::incoming: end new body piece 1.\n"); 195 printf("HttpComm::incoming: end new body piece 1.\n");
190 status=0; 196 status=0;
191 tempQString = tempQString.remove(0, clength); 197 tempQString = tempQString.remove(0, newTQstring.length());
198 startclength = tempQString.find('\n');
199 printf("HttpComm::incoming: startclength: %d\n", startclength);
200 tempQString = tempQString.remove(0, startclength+1);
192 done=false; 201 done=false;
193 // break; 202 // break;
194 } 203 }
@@ -197,11 +206,13 @@ void HttpComm::incoming()
197 { 206 {
198 if(tempQString.length() <= ba) 207 if(tempQString.length() <= ba)
199 { 208 {
209 printf("HttpComm::incoming: not truncating tempQString\n");
200 body+=tempQString; 210 body+=tempQString;
201 bRead+=tempQString.length(); 211 bRead+=tempQString.length();
202 } 212 }
203 else 213 else
204 { 214 {
215 printf("HttpComm::incoming: truncating tempQString\n");
205 tempQString.truncate(ba); 216 tempQString.truncate(ba);
206 body+=tempQString; 217 body+=tempQString;
207 bRead+=tempQString.length(); 218 bRead+=tempQString.length();
@@ -227,7 +238,10 @@ void HttpComm::incoming()
227 printf("%s", newTQstring.latin1() ); 238 printf("%s", newTQstring.latin1() );
228 printf("HttpComm::incoming: end new body piece 3.\n"); 239 printf("HttpComm::incoming: end new body piece 3.\n");
229 status=0; 240 status=0;
230 tempQString = tempQString.remove(0, clength); 241 tempQString = tempQString.remove(0, newTQstring.length());
242 startclength = tempQString.find('\n');
243 printf("HttpComm::incoming: startclength, tempQString length: %d %d\n", startclength, tempQString.length());
244 tempQString = tempQString.remove(0, startclength+1);
231 done=false; 245 done=false;
232 // break; 246 // break;
233 } 247 }
@@ -236,11 +250,13 @@ void HttpComm::incoming()
236 { 250 {
237 if(tempQString.length() <= ba) 251 if(tempQString.length() <= ba)
238 { 252 {
253 printf("HttpComm::incoming: not truncating tempQString\n");
239 body+=tempQString; 254 body+=tempQString;
240 bRead+=tempQString.length(); 255 bRead+=tempQString.length();
241 } 256 }
242 else 257 else
243 { 258 {
259 printf("HttpComm::incoming: truncating tempQString\n");
244 tempQString.truncate(ba); 260 tempQString.truncate(ba);
245 body+=tempQString; 261 body+=tempQString;
246 bRead+=tempQString.length(); 262 bRead+=tempQString.length();
@@ -308,10 +324,19 @@ void HttpComm::processBody()
308 324
309 QString end = file; 325 QString end = file;
310 end.truncate(lastSlash+1); 326 end.truncate(lastSlash+1);
311 QString context("http://"+host+':'+portS+end); 327 QString context = "http://"+host+':'+portS+end;
312 printf("HttpComm::processBody: context: %s\n", context.latin1() ); 328 printf("HttpComm::processBody: context: %s\n", context.latin1() );
313 329
314 browser->setTextFormat(RichText); 330 if(!isImage)
315 browser->mimeSourceFactory()->setFilePath(context); 331 {
316 browser->setText(body, context); 332 browser->setTextFormat(RichText);
333 browser->mimeSourceFactory()->setFilePath(context);
334 browser->setText(body, context);
335 }
336 else
337 {
338 QImage tempImage(body.latin1());
339 image->setImage(tempImage);
340 browser->update();
341 }
317} 342}