2024年1月30日发(作者:)
sprintf(length,"%d",contentLength); memset(data,0,MAXLINE); Pipe(p); /* The post data is sended by client,we need to redirct the data to cgi stdin. * so, child read contentLength bytes data from fp,and write to p[1]; * parent should redirct p[0] to stdin. As a result, the cgi script can * read the post data from the stdin.
*/ /* https already read all data ,include post data by SSL_read() */
if (Fork() == 0) { /* child */
Close(p[0]); #ifdef HTTPS
if(ishttps) { Write(p[1],httpspostdata,contentLength);
} else #endif { Rio_readnb(rp,data,contentLength); Rio_writen(p[1],data,contentLength); } exit(0) ; }
/* Send response headers to client */ sprintf(buf, "HTTP/1.0 200 OKrn"); sprintf(buf, "%sServer: Tiny Web Serverrn",buf); #ifdef HTTPS
if(ishttps) SSL_write(ssl,buf,strlen(buf)); else #endif Rio_writen(fd, buf, strlen(buf)); Dup2(p[0],STDIN_FILENO); /* Redirct p[0] to stdin */ Close(p[0]); Close(p[1]); setenv("CONTENT-LENGTH",length , 1);
#ifdef HTTPS
if(ishttps) /* if ishttps,we couldnot redirct stdout to client,we must use SSL_write */ { Pipe(httpsp); if(Fork()==0) { Dup2(httpsp[1],STDOUT_FILENO); /* Redirct stdout to https[1] */
Execve(filename, emptylist, environ);
} Read(httpsp[0],data,MAXLINE); SSL_write(ssl,data,strlen(data)); } else
本文发布于:2024-01-30 22:04:22,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170662346223146.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |