Lines Matching refs:req

124 static int ProcessRequest(struct httprequest *req);
206 static int ProcessRequest(struct httprequest *req)
208 char *line = &req->reqbuf[req->checkindex];
217 req->testno, line);
221 if((req->testno == DOCNUMBER_NOTHING) &&
233 req->protocol = RPROT_HTTP;
236 req->protocol = RPROT_RTSP;
239 req->protocol = RPROT_NONE;
244 req->prot_version = prot_major*10 + prot_minor;
262 req->testno = DOCNUMBER_WERULEZ;
268 req->testno = DOCNUMBER_QUIT;
278 req->testno = strtol(ptr, &ptr, 10);
280 if(req->testno > 10000) {
281 req->partno = req->testno % 10000;
282 req->testno /= 10000;
285 req->partno = 0;
288 req->testno, req->partno);
291 stream = test2fopen(req->testno, logdir);
296 logmsg("Couldn't open test file %ld", req->testno);
297 req->open = FALSE; /* closes connection */
316 req->open = FALSE; /* closes connection */
327 req->auth_req = TRUE;
331 req->rcmd = RCMD_IDLE;
332 req->open = TRUE;
336 req->rcmd = RCMD_STREAM;
343 req->pipe = num-1; /* decrease by one since we don't count the
348 req->skip = num;
355 if(rtp_partno == req->partno) {
378 if(!req->rtp_buffer) {
379 req->rtp_buffer = rtp_scratch;
380 req->rtp_buffersize = rtp_size + 4;
383 req->rtp_buffer = realloc(req->rtp_buffer,
384 req->rtp_buffersize +
386 memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch,
388 req->rtp_buffersize += rtp_size + 4;
392 req->rtp_buffersize, rtp_size);
411 if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
418 if(req->prot_version == 10)
419 req->open = FALSE; /* HTTP 1.0 closes connection by default */
423 req->testno = DOCNUMBER_BADCONNECT;
429 req->testno = strtol(portp + 1, NULL, 10);
431 req->testno = DOCNUMBER_CONNECT;
434 req->testno = DOCNUMBER_CONNECT;
438 req->testno = DOCNUMBER_404;
450 if(req->pipe)
453 req->checkindex += (end - line) + strlen(END_OF_HEADERS);
470 if((req->cl == 0) && strncasecompare("Content-Length:", line, 15)) {
486 req->open = FALSE; /* closes connection */
489 req->cl = clen - req->skip;
492 if(req->skip)
493 logmsg("... but will abort after %zu bytes", req->cl);
503 if(strstr(req->reqbuf, "\r\n0\r\n\r\n"))
516 if(!req->auth && strstr(req->reqbuf, "Authorization:")) {
517 req->auth = TRUE; /* Authorization: header present! */
518 if(req->auth_req)
522 if(!req->digest && strstr(req->reqbuf, "Authorization: Digest")) {
526 req->partno += 1000;
527 req->digest = TRUE; /* header found */
528 logmsg("Received Digest request, sending back data %ld", req->partno);
530 else if(!req->ntlm &&
531 strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAD")) {
533 req->partno += 1002;
534 req->ntlm = TRUE; /* NTLM found */
535 logmsg("Received NTLM type-3, sending back data %ld", req->partno);
536 if(req->cl) {
537 logmsg(" Expecting %zu POSTed bytes", req->cl);
540 else if(!req->ntlm &&
541 strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAB")) {
543 req->partno += 1001;
544 req->ntlm = TRUE; /* NTLM found */
545 logmsg("Received NTLM type-1, sending back data %ld", req->partno);
547 else if((req->partno >= 1000) &&
548 strstr(req->reqbuf, "Authorization: Basic")) {
552 req->partno += 1;
553 logmsg("Received Basic request, sending back data %ld", req->partno);
555 if(strstr(req->reqbuf, "Connection: close"))
556 req->open = FALSE; /* close connection after this request */
558 if(!req->pipe &&
559 req->open &&
560 req->prot_version >= 11 &&
561 req->reqbuf + req->offset > end + strlen(END_OF_HEADERS) &&
562 (!strncmp(req->reqbuf, "GET", strlen("GET")) ||
563 !strncmp(req->reqbuf, "HEAD", strlen("HEAD")))) {
566 req->checkindex = (end - req->reqbuf) + strlen(END_OF_HEADERS);
567 req->pipelining = TRUE;
570 while(req->pipe) {
574 line = &req->reqbuf[req->checkindex];
578 req->checkindex += (end - line) + strlen(END_OF_HEADERS);
579 req->pipe--;
586 if(req->auth_req && !req->auth)
589 if(req->cl > 0) {
590 if(req->cl <= req->offset - (end - req->reqbuf) - strlen(END_OF_HEADERS))
656 static int get_request(curl_socket_t sock, struct httprequest *req)
661 char *reqbuf = req->reqbuf;
667 if(req->pipelining) {
668 pipereq = reqbuf + req->checkindex;
669 pipereq_length = req->offset - req->checkindex;
674 req->checkindex = 0;
675 req->offset = 0;
676 req->testno = DOCNUMBER_NOTHING;
677 req->partno = 0;
678 req->open = TRUE;
679 req->auth_req = FALSE;
680 req->auth = FALSE;
681 req->cl = 0;
682 req->digest = FALSE;
683 req->ntlm = FALSE;
684 req->pipe = 0;
685 req->skip = 0;
686 req->rcmd = RCMD_NORMALREQ;
687 req->protocol = RPROT_NONE;
688 req->prot_version = 0;
689 req->pipelining = FALSE;
690 req->rtp_buffer = NULL;
691 req->rtp_buffersize = 0;
695 while(!done_processing && (req->offset < REQBUFSIZ-1)) {
702 if(req->skip)
706 got = sread(sock, reqbuf + req->offset, req->cl);
708 got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset);
723 reqbuf[req->offset] = '\0';
724 storerequest(reqbuf, req->offset);
730 req->offset += (size_t)got;
731 reqbuf[req->offset] = '\0';
733 done_processing = ProcessRequest(req);
736 if(done_processing && req->pipe) {
739 req->pipe--;
743 if((req->offset == REQBUFSIZ-1) && (got > 0)) {
749 else if(req->offset > REQBUFSIZ-1) {
756 reqbuf[req->offset] = '\0';
759 storerequest(reqbuf, req->pipelining ? req->checkindex : req->offset);
767 static int send_doc(curl_socket_t sock, struct httprequest *req)
787 logmsg("Send response number %ld part %ld", req->testno, req->partno);
789 switch(req->rcmd) {
811 req->open = FALSE;
813 if(req->testno < 0) {
817 switch(req->testno) {
847 if(req->protocol == RPROT_HTTP) {
859 FILE *stream = test2fopen(req->testno, logdir);
861 if(0 != req->partno)
862 msnprintf(partbuf, sizeof(partbuf), "data%ld", req->partno);
885 stream = test2fopen(req->testno, logdir);
962 if(req->rtp_buffer) {
963 logmsg("About to write %zu RTP bytes", req->rtp_buffersize);
964 count = req->rtp_buffersize;
969 written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count),
978 free(req->rtp_buffer);
979 req->rtp_buffersize = 0;
1045 req->open = persistent;
1047 prevtestno = req->testno;
1048 prevpartno = req->partno;
1065 struct httprequest req;
1070 memset(&req, 0, sizeof(req));
1317 req.pipelining = FALSE;
1323 if(get_request(msgsock, &req))
1329 if((req.testno == prevtestno) &&
1330 (req.partno == prevpartno)) {
1331 req.partno++;
1332 logmsg("BOUNCE part number to %ld", req.partno);
1341 send_doc(msgsock, &req);
1345 if((req.testno < 0) && (req.testno != DOCNUMBER_CONNECT)) {
1349 if(!req.open) {
1354 if(req.open)
1357 } while(req.open || (req.testno == DOCNUMBER_CONNECT));
1371 if(req.testno == DOCNUMBER_QUIT)