summaryrefslogtreecommitdiff
path: root/noncore/net/ubrowser/httpcomm.cpp
Unidiff
Diffstat (limited to 'noncore/net/ubrowser/httpcomm.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/ubrowser/httpcomm.cpp47
1 files changed, 43 insertions, 4 deletions
diff --git a/noncore/net/ubrowser/httpcomm.cpp b/noncore/net/ubrowser/httpcomm.cpp
index 51068db..54f7acf 100644
--- a/noncore/net/ubrowser/httpcomm.cpp
+++ b/noncore/net/ubrowser/httpcomm.cpp
@@ -133,72 +133,111 @@ void HttpComm::incoming()
133 else 133 else
134 { 134 {
135 QString tempQString = tempString; 135 QString tempQString = tempString;
136 //remove the http header, if one exists 136 //remove the http header, if one exists
137 if(j != 0) 137 if(j != 0)
138 { 138 {
139 tempQString.remove(0, j); 139 tempQString.remove(0, j+1);
140 printf("HttpComm::incoming: removing http header. Result: \n%s", tempQString.latin1());
140 } 141 }
141 while(!done) 142 while(!done)
142 { 143 {
143 switch(status) 144 switch(status)
144 { 145 {
145 //case 0=need to read chunk length 146 //case 0=need to read chunk length
146 case 0: 147 case 0:
147 j = tempQString.find('\n'); 148 j = tempQString.find('\n');
148 sclength = tempQString; 149 sclength = tempQString;
149 sclength.truncate(j); 150 sclength.truncate(j);
150 clength = sclength.toUInt(0, 16); 151 clength = sclength.toUInt(0, 16);
151 printf("HttpComm::Incoming: chunk length: %d\n", clength); 152 printf("HttpComm::Incoming: chunk length: %d\n", clength);
153 //end of data
152 if(clength==0) 154 if(clength==0)
153 { 155 {
154 processBody(); 156 processBody();
155 done=true; 157 done=true;
156 } 158 }
159 //still more, but it hasnt been recieved yet
157 if(ba <= j) 160 if(ba <= j)
158 { 161 {
159 status=1; 162 status=1;
160 done=true; 163 done=true;
161 // break; 164 break;
162 } 165 }
166 //still more data waiting
163 else 167 else
164 { 168 {
165 done=false; 169 done=false;
170 //remove the chunk length header
171 tempQString.remove(0,j+1);
166 } 172 }
167 bRead=0; 173 bRead=0;
168 break; 174 // break;
169 //if there is more fall through to: 175 //if there is more fall through to:
170 //chunk length just read, still more in tempQstring 176 //chunk length just read, still more in tempQstring
171 case 1: 177 case 1:
172 //the current data extends beyond the end of the chunk 178 //the current data extends beyond the end of the chunk
173 if(bRead + tempQString.length() > clength) 179 if(bRead + tempQString.length() > clength)
174 { 180 {
175 QString newTQstring = tempQString; 181 QString newTQstring = tempQString;
176 newTQstring.truncate(clength-bRead); 182 newTQstring.truncate(clength-bRead);
183 bRead+=newTQstring.length();
177 body+=newTQstring; 184 body+=newTQstring;
178 printf("HttpComm::incoming: start new body piece 1: \n"); 185 printf("HttpComm::incoming: start new body piece 1: \n");
179 printf("%s", newTQstring.latin1() ); 186 printf("%s", newTQstring.latin1() );
180 printf("HttpComm::incoming: end new body piece 1.\n"); 187 printf("HttpComm::incoming: end new body piece 1.\n");
181 status=0; 188 status=0;
182 j=clength-bRead; 189 j=clength-bRead;
183 done=false; 190 done=false;
184 break; 191 // break;
185 } 192 }
186 //the chunk extends beyond the current data; 193 //the chunk extends beyond the current data;
187 else 194 else
188 { 195 {
189 body+=tempQString; 196 body+=tempQString;
190 bRead+=ba; 197 bRead+=ba;
191 printf("HttpComm::incoming: start new body piece 2: \n"); 198 printf("HttpComm::incoming: start new body piece 2: \n");
192 printf("%s", tempQString.latin1() ); 199 printf("%s", tempQString.latin1() );
193 printf("HttpComm::incoming: end new body piece 2.\n"); 200 printf("HttpComm::incoming: end new body piece 2.\n");
194 done=true; 201 done=true;
202 status=2;
203 // break;
204 }
195 break; 205 break;
206 //just got data in, continue reading chunk
207 case 2:
208 //the current data extends beyond the end of the chunk
209 if(bRead + tempQString.length() > clength)
210 {
211 QString newTQstring = tempQString;
212 newTQstring.truncate(clength-bRead);
213 bRead+=newTQstring.length();
214 body+=newTQstring;
215 printf("HttpComm::incoming: start new body piece 3: \n");
216 printf("%s", newTQstring.latin1() );
217 printf("HttpComm::incoming: end new body piece 3.\n");
218 status=0;
219 j=clength-bRead;
220 done=false;
221 // break;
222 }
223 //the chunk extends beyond the current data;
224 else
225 {
226 body+=tempQString;
227 bRead+=ba;
228 printf("HttpComm::incoming: start new body piece 4: \n");
229 printf("%s", tempQString.latin1() );
230 printf("HttpComm::incoming: end new body piece 4.\n");
231 done=true;
232 status=2;
233 // break;
196 } 234 }
197 break; 235 break;
198 } 236 }
237 printf("HttpComm::incoming: chunked encoding: bRead: %d\n", bRead);
199 } 238 }
200 } 239 }
201 } 240 }
202 delete tempString; 241 delete tempString;
203} 242}
204 243