本文整理汇总了C++中HTTPRequest::httpParse方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPRequest::httpParse方法的具体用法?C++ HTTPRequest::httpParse怎么用?C++ HTTPRequest::httpParse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::httpParse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readHandler
/** @brief read handler
* @return void
*/
void SelPool::readHandler(ClientConnection *client)
{
if (client->isFull()) {
return;
}
ssize_t size;
int retSize = 0;
char* buf = client->getReadBuffer_ForWrite(&size);
int connFd = client->getFd();
//printf("reading client %d\n", connFd);
if(client->isHTTP()) {
printf( "HTTP client ...\n");
retSize = read(connFd, buf, size);
}
else if(client->isHTTPS()) {
printf( "HTTPS client ...\n");
//retSize = SSL_read(connPtr->connSSL, buf, size);
}
else {
retSize = -1;
}
if (retSize > 0)
{
printf("Successfully Read %d Bytes from client %d\n", retSize, client->getFd());
client->addReadSize(retSize);
/* get read buffer */
ssize_t size;
char* parse_buf = client->getReadBuffer_ForRead(&size);
/* try to parse the request from buffer */
HTTPRequest *req = client->getRequest();
req->httpParse(parse_buf, &size);
client->removeReadSize(size);
// TODO: to add a status "Request_Parsing"
if (client->getRequest()->getState() == HTTPRequest::ParsedCorrect
|| client->getRequest()->getState() == HTTPRequest::ParsedError) {
client->setState(ClientConnection::Request_Parsed);
}
}
/** EOF incurred, connection closed by client */
else if (retSize == 0)
{
printf("set Client [%d] closed\n", connFd);
client->setClosed();
client->setState(ClientConnection::Request_Parsed);
return;
}
else /* Read error: retSize < 0 */
{
printf("Error reading from client.\n");
if(client->isHTTPS())
{
// int err = SSL_get_error(connPtr->connSSL, retSize);
// switch(err)
// {
// case SSL_ERROR_WANT_READ:
// case SSL_ERROR_WANT_WRITE:
// printf("SSL WANT MORE.\n");
// return;
// default:
// ERR_print_errors_fp(getLogger());
// break;
// }
}
else
{
if(errno == EINTR) {
printf("RECV EINTR. Try later again.\n");
return;
}
}
client->setClosed();
return;
}
}