Home | History | Annotate | Download | only in server

Lines Matching refs:req

124 static int ProcessRequest(struct httprequest *req);
336 static int ProcessRequest(struct httprequest *req)
338 char *line = &req->reqbuf[req->checkindex];
350 req->testno, line);
354 if((req->testno == DOCNUMBER_NOTHING) &&
365 req->protocol = RPROT_HTTP;
368 req->protocol = RPROT_RTSP;
371 req->protocol = RPROT_NONE;
376 req->prot_version = prot_major*10 + prot_minor;
396 req->testno = DOCNUMBER_WERULEZ;
402 req->testno = DOCNUMBER_QUIT;
412 req->testno = strtol(ptr, &ptr, 10);
414 if(req->testno > 10000) {
415 req->partno = req->testno % 10000;
416 req->testno /= 10000;
419 req->partno = 0;
422 req->testno, req->partno);
425 filename = test2file(req->testno);
432 logmsg("Couldn't open test file %ld", req->testno);
433 req->open = FALSE; /* closes connection */
452 req->open = FALSE; /* closes connection */
462 req->auth_req = TRUE;
466 req->rcmd = RCMD_IDLE;
467 req->open = TRUE;
471 req->rcmd = RCMD_STREAM;
478 req->pipe = num-1; /* decrease by one since we don't count the
483 req->skip = num;
488 if(rtp_partno == req->partno) {
510 if(req->rtp_buffer == NULL) {
511 req->rtp_buffer = rtp_scratch;
512 req->rtp_buffersize = rtp_size + 4;
515 req->rtp_buffer = realloc(req->rtp_buffer,
516 req
518 memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch,
520 req->rtp_buffersize += rtp_size + 4;
524 req->rtp_buffersize, rtp_size);
543 if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
550 if(req->prot_version == 10)
551 req->open = FALSE; /* HTTP 1.0 closes connection by default */
555 req->testno = DOCNUMBER_BADCONNECT;
561 req->testno = strtol(portp + 1, NULL, 10);
563 req->testno = DOCNUMBER_CONNECT;
566 req->testno = DOCNUMBER_CONNECT;
570 req->testno = DOCNUMBER_404;
582 if(req->pipe)
585 req->checkindex += (end - line) + strlen(END_OF_HEADERS);
602 if((req->cl == 0) && strncasecompare("Content-Length:", line, 15)) {
618 req->open = FALSE; /* closes connection */
621 req->cl = clen - req->skip;
624 if(req->skip)
625 logmsg("... but will abort after %zu bytes", req->cl);
635 if(strstr(req->reqbuf, "\r\n0\r\n\r\n"))
648 if(!req->auth && strstr(req->reqbuf, "Authorization:")) {
649 req->auth = TRUE; /* Authorization: header present! */
650 if(req->auth_req)
654 if(!req->digest && strstr(req->reqbuf, "Authorization: Digest")) {
658 req->partno += 1000;
659 req->digest = TRUE; /* header found */
660 logmsg("Received Digest request, sending back data %ld", req->partno);
662 else if(!req->ntlm &&
663 strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAD")) {
665 req->partno += 1002;
666 req->ntlm = TRUE; /* NTLM found */
667 logmsg("Received NTLM type-3, sending back data %ld", req->partno);
668 if(req->cl) {
669 logmsg(" Expecting %zu POSTed bytes", req->cl);
672 else if(!req->ntlm &&
673 strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAB")) {
675 req->partno += 1001;
676 req->ntlm = TRUE; /* NTLM found */
677 logmsg("Received NTLM type-1, sending back data %ld", req->partno);
679 else if((req->partno >= 1000) &&
680 strstr(req->reqbuf, "Authorization: Basic")) {
684 req->partno += 1;
685 logmsg("Received Basic request, sending back data %ld", req->partno);
687 if(strstr(req->reqbuf, "Connection: close"))
688 req->open = FALSE; /* close connection after this request */
690 if(!req->pipe &&
691 req->open &&
692 req->prot_version >= 11 &&
694 req->reqbuf + req->offset > end + strlen(END_OF_HEADERS) &&
695 (!strncmp(req->reqbuf, "GET", strlen("GET")) ||
696 !strncmp(req->reqbuf, "HEAD", strlen("HEAD")))) {
699 req->checkindex = (end - req->reqbuf) + strlen(END_OF_HEADERS);
700 req->pipelining = TRUE;
703 while(req->pipe) {
707 line = &req->reqbuf[req->checkindex];
711 req->checkindex += (end - line) + strlen(END_OF_HEADERS);
712 req->pipe--;
719 if(req->auth_req && !req->auth)
722 if(req->cl > 0) {
723 if(req->cl <= req->offset - (end - req->reqbuf) - strlen(END_OF_HEADERS))
786 static int get_request(curl_socket_t sock, struct httprequest *req)
791 char *reqbuf = req->reqbuf;
797 if(req->pipelining) {
798 pipereq = reqbuf + req->checkindex;
799 pipereq_length = req->offset - req->checkindex;
804 req->checkindex = 0;
805 req->offset = 0;
806 req->testno = DOCNUMBER_NOTHING;
807 req->partno = 0;
808 req->open = TRUE;
809 req->auth_req = FALSE;
810 req->auth = FALSE;
811 req->cl = 0;
812 req->digest = FALSE;
813 req->ntlm = FALSE;
814 req->pipe = 0;
815 req->skip = 0;
816 req->rcmd = RCMD_NORMALREQ;
817 req->protocol = RPROT_NONE;
818 req->prot_version = 0;
819 req->pipelining = FALSE;
820 req->rtp_buffer = NULL;
821 req->rtp_buffersize = 0;
825 while(!done_processing && (req->offset < REQBUFSIZ-1)) {
832 if(req->skip)
836 got = sread(sock, reqbuf + req->offset, req->cl);
838 got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset);
853 reqbuf[req->offset] = '\0';
854 storerequest(reqbuf, req->offset);
860 req->offset += (size_t)got;
861 reqbuf[req->offset] = '\0';
863 done_processing = ProcessRequest(req);
866 if(done_processing && req->pipe) {
869 req->pipe--;
873 if((req->offset == REQBUFSIZ-1) && (got > 0)) {
879 else if(req->offset > REQBUFSIZ-1) {
886 reqbuf[req->offset] = '\0';
889 storerequest(reqbuf, req->pipelining ? req->checkindex : req->offset);
897 static int send_doc(curl_socket_t sock, struct httprequest *req)
917 logmsg("Send response number %ld part %ld", req->testno, req->partno);
919 switch(req->rcmd) {
941 req->open = FALSE;
943 if(req->testno < 0) {
947 switch(req->testno) {
977 if(req->protocol == RPROT_HTTP) {
989 char *filename = test2file(req->testno);
991 if(0 != req->partno)
992 snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno);
1096 if(req->rtp_buffer) {
1097 logmsg("About to write %zu RTP bytes", req->rtp_buffersize);
1098 count = req->rtp_buffersize;
1103 written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count),
1112 free(req->rtp_buffer);
1113 req->rtp_buffersize = 0;
1179 req->open = persistant;
1181 prevtestno = req->testno;
1182 prevpartno = req->partno;
1197 struct httprequest req;
1203 memset(&req, 0, sizeof(req));
1395 req.pipelining = FALSE;
1401 if(get_request(msgsock, &req))
1407 if((req.testno == prevtestno) &&
1408 (req.partno == prevpartno)) {
1409 req.partno++;
1410 logmsg("BOUNCE part number to %ld", req.partno);
1419 send_doc(msgsock, &req);
1423 if((req.testno < 0) && (req.testno != DOCNUMBER_CONNECT)) {
1427 if(!req.open) {
1432 if(req.open)
1435 } while(req.open || (req.testno == DOCNUMBER_CONNECT));
1449 if(req.testno == DOCNUMBER_QUIT)