~george-edison55/jethttp/jethttp-multithread

« back to all changes in this revision

Viewing changes to CHTTPServer.cpp

  • Committer: Nathan Osman
  • Date: 2010-10-28 01:16:03 UTC
  • Revision ID: admin@quickmediasolutions.com-20101028011603-ocq07h2slpdmuadz
Fixed long processing time on POST requests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
            path.append(m_default_name);
174
174
    }
175
175
 
 
176
    // Send the status signal
 
177
    emit statusString(tr("Page '%1' requested...").arg(path));
 
178
 
 
179
    QList< QPair< QString,QString > > header_list;
 
180
    ReadHeader(request,header_list);
 
181
 
 
182
    int content_length = 0;
 
183
 
 
184
    QString val;
 
185
    if(FindHeader(header_list,"content-length",val))
 
186
        content_length = val.toInt();
 
187
 
176
188
    bool bPost = false;
177
189
 
178
190
    if(status.at(0) == "POST")
183
195
        // One of them is to read the rest of the
184
196
        // content from the socket.
185
197
 
186
 
        while(pSocket->waitForReadyRead())
 
198
        do
187
199
        {
 
200
            if(content_length)
 
201
                if(content_length == request.size())
 
202
                    break;
 
203
 
188
204
            request.append(pSocket->readAll());
189
 
        }
 
205
 
 
206
        } while(pSocket->waitForReadyRead());
190
207
 
191
208
        // The post data should be at the end of
192
209
        // the content
194
211
        bPost = true;
195
212
    }
196
213
 
197
 
    // Send the status signal
198
 
    emit statusString(tr("Page '%1' requested...").arg(path));
199
 
 
200
 
    QList< QPair< QString,QString > > header_list;
201
 
    ReadHeader(request,header_list);
202
 
 
203
 
    int content_length = 0;
204
 
 
205
 
    QString val;
206
 
    if(FindHeader(header_list,"content-length",val))
207
 
        content_length = val.toInt();
208
 
 
209
214
    // Check to see if the requested file is a PHP file
210
215
    if(path.contains('.'))
211
216
    {