Lines Matching refs:req
121 static int ProcessRequest(struct httprequest *req);
203 static int ProcessRequest(struct httprequest *req) in ProcessRequest() argument
205 char *line = &req->reqbuf[req->checkindex]; in ProcessRequest()
214 req->testno, line); in ProcessRequest()
218 if((req->testno == DOCNUMBER_NOTHING) && in ProcessRequest()
230 req->protocol = RPROT_HTTP; in ProcessRequest()
233 req->protocol = RPROT_RTSP; in ProcessRequest()
236 req->protocol = RPROT_NONE; in ProcessRequest()
241 req->prot_version = prot_major*10 + prot_minor; in ProcessRequest()
259 req->testno = DOCNUMBER_WERULEZ; in ProcessRequest()
265 req->testno = DOCNUMBER_QUIT; in ProcessRequest()
275 req->testno = strtol(ptr, &ptr, 10); in ProcessRequest()
277 if(req->testno > 10000) { in ProcessRequest()
278 req->partno = req->testno % 10000; in ProcessRequest()
279 req->testno /= 10000; in ProcessRequest()
282 req->partno = 0; in ProcessRequest()
285 req->testno, req->partno); in ProcessRequest()
288 stream = test2fopen(req->testno, logdir); in ProcessRequest()
293 logmsg("Couldn't open test file %ld", req->testno); in ProcessRequest()
294 req->open = FALSE; /* closes connection */ in ProcessRequest()
313 req->open = FALSE; /* closes connection */ in ProcessRequest()
324 req->auth_req = TRUE; in ProcessRequest()
328 req->rcmd = RCMD_IDLE; in ProcessRequest()
329 req->open = TRUE; in ProcessRequest()
333 req->rcmd = RCMD_STREAM; in ProcessRequest()
340 req->pipe = num-1; /* decrease by one since we don't count the in ProcessRequest()
345 req->skip = num; in ProcessRequest()
352 if(rtp_partno == req->partno) { in ProcessRequest()
375 if(!req->rtp_buffer) { in ProcessRequest()
376 req->rtp_buffer = rtp_scratch; in ProcessRequest()
377 req->rtp_buffersize = rtp_size + 4; in ProcessRequest()
380 req->rtp_buffer = realloc(req->rtp_buffer, in ProcessRequest()
381 req->rtp_buffersize + in ProcessRequest()
383 memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch, in ProcessRequest()
385 req->rtp_buffersize += rtp_size + 4; in ProcessRequest()
389 req->rtp_buffersize, rtp_size); in ProcessRequest()
408 if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", in ProcessRequest()
415 if(req->prot_version == 10) in ProcessRequest()
416 req->open = FALSE; /* HTTP 1.0 closes connection by default */ in ProcessRequest()
420 req->testno = DOCNUMBER_BADCONNECT; in ProcessRequest()
426 req->testno = strtol(portp + 1, NULL, 10); in ProcessRequest()
428 req->testno = DOCNUMBER_CONNECT; in ProcessRequest()
431 req->testno = DOCNUMBER_CONNECT; in ProcessRequest()
435 req->testno = DOCNUMBER_404; in ProcessRequest()
447 if(req->pipe) in ProcessRequest()
450 req->checkindex += (end - line) + strlen(END_OF_HEADERS); in ProcessRequest()
467 if((req->cl == 0) && strncasecompare("Content-Length:", line, 15)) { in ProcessRequest()
483 req->open = FALSE; /* closes connection */ in ProcessRequest()
486 req->cl = clen - req->skip; in ProcessRequest()
489 if(req->skip) in ProcessRequest()
490 logmsg("... but will abort after %zu bytes", req->cl); in ProcessRequest()
500 if(strstr(req->reqbuf, "\r\n0\r\n\r\n")) in ProcessRequest()
513 if(!req->auth && strstr(req->reqbuf, "Authorization:")) { in ProcessRequest()
514 req->auth = TRUE; /* Authorization: header present! */ in ProcessRequest()
515 if(req->auth_req) in ProcessRequest()
519 if(!req->digest && strstr(req->reqbuf, "Authorization: Digest")) { in ProcessRequest()
523 req->partno += 1000; in ProcessRequest()
524 req->digest = TRUE; /* header found */ in ProcessRequest()
525 logmsg("Received Digest request, sending back data %ld", req->partno); in ProcessRequest()
527 else if(!req->ntlm && in ProcessRequest()
528 strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAD")) { in ProcessRequest()
530 req->partno += 1002; in ProcessRequest()
531 req->ntlm = TRUE; /* NTLM found */ in ProcessRequest()
532 logmsg("Received NTLM type-3, sending back data %ld", req->partno); in ProcessRequest()
533 if(req->cl) { in ProcessRequest()
534 logmsg(" Expecting %zu POSTed bytes", req->cl); in ProcessRequest()
537 else if(!req->ntlm && in ProcessRequest()
538 strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAB")) { in ProcessRequest()
540 req->partno += 1001; in ProcessRequest()
541 req->ntlm = TRUE; /* NTLM found */ in ProcessRequest()
542 logmsg("Received NTLM type-1, sending back data %ld", req->partno); in ProcessRequest()
544 else if((req->partno >= 1000) && in ProcessRequest()
545 strstr(req->reqbuf, "Authorization: Basic")) { in ProcessRequest()
549 req->partno += 1; in ProcessRequest()
550 logmsg("Received Basic request, sending back data %ld", req->partno); in ProcessRequest()
552 if(strstr(req->reqbuf, "Connection: close")) in ProcessRequest()
553 req->open = FALSE; /* close connection after this request */ in ProcessRequest()
555 if(!req->pipe && in ProcessRequest()
556 req->open && in ProcessRequest()
557 req->prot_version >= 11 && in ProcessRequest()
558 req->reqbuf + req->offset > end + strlen(END_OF_HEADERS) && in ProcessRequest()
559 (!strncmp(req->reqbuf, "GET", strlen("GET")) || in ProcessRequest()
560 !strncmp(req->reqbuf, "HEAD", strlen("HEAD")))) { in ProcessRequest()
563 req->checkindex = (end - req->reqbuf) + strlen(END_OF_HEADERS); in ProcessRequest()
564 req->pipelining = TRUE; in ProcessRequest()
567 while(req->pipe) { in ProcessRequest()
571 line = &req->reqbuf[req->checkindex]; in ProcessRequest()
575 req->checkindex += (end - line) + strlen(END_OF_HEADERS); in ProcessRequest()
576 req->pipe--; in ProcessRequest()
583 if(req->auth_req && !req->auth) in ProcessRequest()
586 if(req->cl > 0) { in ProcessRequest()
587 if(req->cl <= req->offset - (end - req->reqbuf) - strlen(END_OF_HEADERS)) in ProcessRequest()
653 static int get_request(curl_socket_t sock, struct httprequest *req) in get_request() argument
658 char *reqbuf = req->reqbuf; in get_request()
664 if(req->pipelining) { in get_request()
665 pipereq = reqbuf + req->checkindex; in get_request()
666 pipereq_length = req->offset - req->checkindex; in get_request()
671 req->checkindex = 0; in get_request()
672 req->offset = 0; in get_request()
673 req->testno = DOCNUMBER_NOTHING; in get_request()
674 req->partno = 0; in get_request()
675 req->open = TRUE; in get_request()
676 req->auth_req = FALSE; in get_request()
677 req->auth = FALSE; in get_request()
678 req->cl = 0; in get_request()
679 req->digest = FALSE; in get_request()
680 req->ntlm = FALSE; in get_request()
681 req->pipe = 0; in get_request()
682 req->skip = 0; in get_request()
683 req->rcmd = RCMD_NORMALREQ; in get_request()
684 req->protocol = RPROT_NONE; in get_request()
685 req->prot_version = 0; in get_request()
686 req->pipelining = FALSE; in get_request()
687 req->rtp_buffer = NULL; in get_request()
688 req->rtp_buffersize = 0; in get_request()
692 while(!done_processing && (req->offset < REQBUFSIZ-1)) { in get_request()
699 if(req->skip) in get_request()
703 got = sread(sock, reqbuf + req->offset, req->cl); in get_request()
705 got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset); in get_request()
720 reqbuf[req->offset] = '\0'; in get_request()
721 storerequest(reqbuf, req->offset); in get_request()
727 req->offset += (size_t)got; in get_request()
728 reqbuf[req->offset] = '\0'; in get_request()
730 done_processing = ProcessRequest(req); in get_request()
733 if(done_processing && req->pipe) { in get_request()
736 req->pipe--; in get_request()
740 if((req->offset == REQBUFSIZ-1) && (got > 0)) { in get_request()
746 else if(req->offset > REQBUFSIZ-1) { in get_request()
753 reqbuf[req->offset] = '\0'; in get_request()
756 storerequest(reqbuf, req->pipelining ? req->checkindex : req->offset); in get_request()
764 static int send_doc(curl_socket_t sock, struct httprequest *req) in send_doc() argument
784 logmsg("Send response number %ld part %ld", req->testno, req->partno); in send_doc()
786 switch(req->rcmd) { in send_doc()
808 req->open = FALSE; in send_doc()
810 if(req->testno < 0) { in send_doc()
814 switch(req->testno) { in send_doc()
844 if(req->protocol == RPROT_HTTP) { in send_doc()
856 FILE *stream = test2fopen(req->testno, logdir); in send_doc()
858 if(0 != req->partno) in send_doc()
859 msnprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); in send_doc()
882 stream = test2fopen(req->testno, logdir); in send_doc()
959 if(req->rtp_buffer) { in send_doc()
960 logmsg("About to write %zu RTP bytes", req->rtp_buffersize); in send_doc()
961 count = req->rtp_buffersize; in send_doc()
966 written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count), in send_doc()
975 free(req->rtp_buffer); in send_doc()
976 req->rtp_buffersize = 0; in send_doc()
1042 req->open = persistent; in send_doc()
1044 prevtestno = req->testno; in send_doc()
1045 prevpartno = req->partno; in send_doc()
1062 struct httprequest req; in main() local
1067 memset(&req, 0, sizeof(req)); in main()
1314 req.pipelining = FALSE; in main()
1320 if(get_request(msgsock, &req)) in main()
1326 if((req.testno == prevtestno) && in main()
1327 (req.partno == prevpartno)) { in main()
1328 req.partno++; in main()
1329 logmsg("BOUNCE part number to %ld", req.partno); in main()
1338 send_doc(msgsock, &req); in main()
1342 if((req.testno < 0) && (req.testno != DOCNUMBER_CONNECT)) { in main()
1346 if(!req.open) { in main()
1351 if(req.open) in main()
1354 } while(req.open || (req.testno == DOCNUMBER_CONNECT)); in main()
1368 if(req.testno == DOCNUMBER_QUIT) in main()