mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
perl update
This commit is contained in:
@@ -12,9 +12,12 @@ SCGIhandle::SCGIhandle(void)
|
||||
|
||||
SCGIhandle::~SCGIhandle()
|
||||
{
|
||||
if (handle.connected) {
|
||||
scgi_disconnect(&handle);
|
||||
}
|
||||
|
||||
scgi_disconnect(&handle);
|
||||
scgi_safe_free(data_buf);
|
||||
buflen = 0;
|
||||
bufsize = 0;
|
||||
|
||||
}
|
||||
|
||||
int SCGIhandle::socketDescriptor()
|
||||
@@ -29,11 +32,7 @@ int SCGIhandle::socketDescriptor()
|
||||
|
||||
int SCGIhandle::disconnect()
|
||||
{
|
||||
if (handle.connected) {
|
||||
return scgi_disconnect(&handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return scgi_disconnect(&handle);
|
||||
}
|
||||
|
||||
int SCGIhandle::connected()
|
||||
@@ -51,11 +50,22 @@ int SCGIhandle::addBody(const char *value)
|
||||
return (int) scgi_add_body(&handle, value);
|
||||
}
|
||||
|
||||
|
||||
int SCGIhandle::sendRequest(const char *host, int port, int timeout)
|
||||
char *SCGIhandle::getBody()
|
||||
{
|
||||
return handle.body;
|
||||
}
|
||||
|
||||
char *SCGIhandle::getParam(const char *name)
|
||||
{
|
||||
return (char *) scgi_get_param(&handle, name);
|
||||
}
|
||||
|
||||
char *SCGIhandle::sendRequest(const char *host, int port, int timeout)
|
||||
{
|
||||
ssize_t len;
|
||||
|
||||
if (!host) {
|
||||
return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (timeout < 1000) {
|
||||
@@ -63,27 +73,30 @@ int SCGIhandle::sendRequest(const char *host, int port, int timeout)
|
||||
}
|
||||
|
||||
if (scgi_connect(&handle, host, port, timeout) == SCGI_SUCCESS) {
|
||||
return (int) scgi_send_request(&handle);
|
||||
if (scgi_send_request(&handle) == SCGI_SUCCESS) {
|
||||
while((len = scgi_recv(&handle, buf, sizeof(buf))) > 0) {
|
||||
if (buflen + len > bufsize) {
|
||||
bufsize = buflen + len + 1024;
|
||||
void *tmp = realloc(data_buf, bufsize);
|
||||
assert(tmp);
|
||||
data_buf = (char *)tmp;
|
||||
|
||||
*(data_buf+buflen) = '\0';
|
||||
}
|
||||
snprintf(data_buf+buflen, bufsize-buflen, "%s", buf);
|
||||
buflen += len;
|
||||
}
|
||||
|
||||
return data_buf;
|
||||
}
|
||||
}
|
||||
|
||||
return -2;
|
||||
return (char *) "";
|
||||
}
|
||||
|
||||
char *SCGIhandle::recv(void)
|
||||
{
|
||||
ssize_t len = scgi_recv(&handle, buf, sizeof(buf));
|
||||
|
||||
if (len > 0) {
|
||||
return (char *)buf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int SCGIhandle::bind(const char *host, int port)
|
||||
{
|
||||
return (int) scgi_bind(host, port, &handle.sock);
|
||||
return (scgi_bind(host, port, &server_sock) == SCGI_SUCCESS) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +104,24 @@ int SCGIhandle::accept(void)
|
||||
{
|
||||
scgi_socket_t client_sock;
|
||||
|
||||
if (scgi_accept(handle.sock, &client_sock, NULL) == SCGI_SUCCESS) {
|
||||
return (int) client_sock;
|
||||
if (scgi_accept(server_sock, &client_sock, NULL) == SCGI_SUCCESS) {
|
||||
if (scgi_parse(client_sock, &handle) == SCGI_SUCCESS) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
closesocket(client_sock);
|
||||
}
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCGIhandle::respond(char *msg)
|
||||
{
|
||||
int b = write(handle.sock, msg, strlen(msg));
|
||||
scgi_disconnect(&handle);
|
||||
scgi_safe_free(data_buf);
|
||||
buflen = 0;
|
||||
bufsize = 0;
|
||||
return b;
|
||||
}
|
||||
|
Reference in New Issue
Block a user