Core/Bnet: Rewrite LoginRESTService using boost::beast instead of gsoap as http backend and extract generic http code to be reusable elsewhere

This commit is contained in:
Shauren
2023-12-17 23:21:10 +01:00
parent 5f00ac4b2b
commit acb5fbd48b
27 changed files with 1439 additions and 1262 deletions
-277
View File
@@ -1,277 +0,0 @@
/*
httpget.c
gSOAP HTTP GET plugin.
See instructions below.
gSOAP XML Web services tools
Copyright (C) 2000-2008, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under ONE of the following licenses:
GPL or the gSOAP public license.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2008 Robert A. van Engelen, Genivia inc. All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
[email protected] / [email protected]
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
Compile & link with stand-alone gSOAP server for HTTP GET support.
Compile & link with gSOAP clients for client-side HTTP GET requests.
Usage (server side):
struct soap soap;
soap_init(&soap);
soap_register_plugin_arg(&soap, http_get, http_get_handler);
...
... = soap_copy(&soap); // copies plugin too but not its data: plugin data is shared since fcopy is not set
...
soap_done(&soap); // detach plugin (calls plugin->fdelete)
You need to define a HTTP GET handling function at the server-side:
int http_get_handler(struct soap*)
which will be called from the plugin upon an HTTP GET request.
The function should return an error code or SOAP_OK;
This function should produce a valid HTTP response, for example:
soap_response(soap, SOAP_HTML); // use this to return HTML ...
soap_response(soap, SOAP_OK); // ... or use this to return a SOAP message
...
soap_send(soap, "<HTML>...</HTML>"); // example HTML
...
soap_end_send(soap);
To get query string key-value pairs within a service routine, use:
char *s;
s = soap_query(soap);
while (s)
{
char *key = soap_query_key(soap, &s);
char *val = soap_query_val(soap, &s);
...
}
This will garble soap->path, which contains the HTTP path of the form:
/path?query
where path and/or ?query may be absent. The path info is obtained from
the HTTP request URL: http://domain/path?query
The URL should not exceed the length of SOAP_TAGLEN. Adjust SOAP_TAGLEN
in stdsoap2.h if necessary.
Usage (client side):
For SOAP GET method calls, declare the service method with protocol GET:
//gsoap ns service method-protocol: someMethod GET
int ns__someMethod(... in-params ..., struct ns__someMethodResponse { ... out-params ... } *);
and to make the call in your code:
struct ns__someMethodResponse res;
soap_call_ns__someMethod(soap, "endpoint", "action", ... in-params ...., &res)
Client code for non-SOAP REST GET:
To use general HTTP GET, for example to retrieve an HTML document, use:
struct soap soap;
char *buf = NULL;
size_t len = 0;
soap_init(&soap);
if (soap_GET(&soap, endpoint, action)
|| soap_begin_recv(&soap))
... connect/recv error ...
else
buf = soap_http_get_body(&soap, &len);
soap_end_recv(&soap);
... process data in buf[0..len-1]
soap_destroy(&soap);
soap_end(&soap);
soap_done(&soap);
The soap_http_get_body() function above returns the HTTP body content
as a string.
*/
#include "httpget.h"
#ifdef __cplusplus
extern "C" {
#endif
const char http_get_id[] = HTTP_GET_ID;
static int http_get_init(struct soap *soap, struct http_get_data *data, int (*handler)(struct soap*));
static void http_get_delete(struct soap *soap, struct soap_plugin *p);
static int http_get_parse(struct soap *soap);
static int http_get_handler(struct soap *soap);
int http_get(struct soap *soap, struct soap_plugin *p, void *arg)
{
p->id = http_get_id;
p->data = (void*)SOAP_MALLOC(soap, sizeof(struct http_get_data));
/* p->fcopy = http_get_copy; obsolete, see note with http_get_copy() */
p->fdelete = http_get_delete;
if (!p->data)
return SOAP_EOM;
if (http_get_init(soap, (struct http_get_data*)p->data, (int (*)(struct soap*))arg))
{
SOAP_FREE(soap, p->data); /* error: could not init */
return SOAP_EOM; /* return error */
}
return SOAP_OK;
}
static int http_get_init(struct soap *soap, struct http_get_data *data, int (*handler)(struct soap*))
{
data->fparse = soap->fparse; /* save old HTTP header parser callback */
data->fget = handler;
data->stat_get = 0;
data->stat_post = 0;
data->stat_fail = 0;
memset((void*)data->hist_min, 0, sizeof(data->hist_min));
memset((void*)data->hist_hour, 0, sizeof(data->hist_hour));
memset((void*)data->hist_day, 0, sizeof(data->hist_day));
soap->fparse = http_get_parse; /* replace HTTP header parser callback with ours */
soap->fget = http_get_handler; /* replace HTTP GET callback with ours */
return SOAP_OK;
}
/* We will share the plugin data among all soap copies created with soap_copy(), so we don't have to define this
static int http_get_copy(struct soap *soap, struct soap_plugin *dst, struct soap_plugin *src)
{
*dst = *src;
return SOAP_OK;
}
*/
static void http_get_delete(struct soap *soap, struct soap_plugin *p)
{
(void)soap;
SOAP_FREE(soap, p->data); /* free allocated plugin data (this function is not called for shared plugin data, but only when the final soap_done() is invoked on the original soap struct) */
}
static int http_get_parse(struct soap *soap)
{
#ifndef WITH_LEAN
time_t t;
#ifdef HAVE_LOCALTIME_R
struct tm T;
#endif
struct tm *pT;
#endif
struct http_get_data *data = (struct http_get_data*)soap_lookup_plugin(soap, http_get_id);
if (!data)
return SOAP_PLUGIN_ERROR;
#ifndef WITH_LEAN
time(&t);
#ifdef HAVE_LOCALTIME_R
pT = localtime_r(&t, &T);
#else
pT = localtime(&t);
#endif
/* updates should be in mutex, but we don't mind some inaccuracy in the count to preserve performance */
data->hist_day[pT->tm_yday]++;
data->hist_day[(pT->tm_yday + 1) % 365] = 0;
data->hist_hour[pT->tm_hour]++;
data->hist_hour[(pT->tm_hour + 1) % 24] = 0;
data->hist_min[pT->tm_min]++;
data->hist_min[(pT->tm_min + 1) % 60] = 0;
#endif
soap->error = data->fparse(soap); /* parse HTTP header */
if (!soap->error)
{
if (soap->status == SOAP_POST)
data->stat_post++; /* update should be in mutex, but we don't mind some inaccuracy in the count */
}
else
{
data->stat_fail++; /* update should be in mutex, but we don't mind some inaccuracy in the count */
}
return soap->error;
}
/******************************************************************************/
static int http_get_handler(struct soap *soap)
{
struct http_get_data *data = (struct http_get_data*)soap_lookup_plugin(soap, http_get_id);
if (!data)
return SOAP_PLUGIN_ERROR;
soap->error = data->fget(soap); /* call user-defined HTTP GET handler */
if (soap->error)
{
/* update should be in mutex, but we don't mind some inaccuracy in the count */
data->stat_fail++;
return soap->error;
}
/* update should be in mutex, but we don't mind some inaccuracy in the count */
data->stat_get++;
return SOAP_OK;
}
/******************************************************************************/
void soap_http_get_stats(struct soap *soap, size_t *stat_get, size_t *stat_post, size_t *stat_fail, size_t **hist_min, size_t **hist_hour, size_t **hist_day)
{
struct http_get_data *data = (struct http_get_data*)soap_lookup_plugin(soap, http_get_id);
if (!data)
return;
if (stat_get)
*stat_get = data->stat_get;
if (stat_post)
*stat_post = data->stat_post;
if (stat_fail)
*stat_fail = data->stat_fail;
if (hist_min)
*hist_min = data->hist_min;
if (hist_hour)
*hist_hour = data->hist_hour;
if (hist_day)
*hist_day = data->hist_day;
}
/* deprecated: use soap_GET instead */
int soap_http_get_connect(struct soap *soap, const char *endpoint, const char *action)
{
return soap_GET(soap, endpoint, action);
}
#ifdef __cplusplus
}
#endif
-84
View File
@@ -1,84 +0,0 @@
/*
httpget.h
gSOAP HTTP GET plugin.
See httpget.c for usage instructions.
gSOAP XML Web services tools
Copyright (C) 2000-2008, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under ONE of the following licenses:
GPL or the gSOAP public license.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2008 Robert A. van Engelen, Genivia inc. All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
[email protected] / [email protected]
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
*/
#ifndef HTTPGET_H
#define HTTPGET_H
#include "stdsoap2.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HTTP_GET_ID "SOAP-HTTP-GET/2.1" /* plugin identification */
extern const char http_get_id[];
/* This is the local plugin data shared among all copies of the soap struct: */
struct http_get_data
{
int (*fparse)(struct soap*); /* to save and call the internal HTTP header parser */
int (*fget)(struct soap*); /* user-defined server-side HTTP GET handler */
size_t stat_get; /* HTTP GET usage statistics */
size_t stat_post; /* HTTP POST usage statistics */
size_t stat_fail; /* HTTP failure statistics */
size_t hist_min[60]; /* Hits by the minute */
size_t hist_hour[24]; /* Hits by the hour */
size_t hist_day[366]; /* Hits by day */
};
int http_get(struct soap*, struct soap_plugin*, void*);
int soap_http_get_connect(struct soap*, const char*, const char*);
void soap_http_get_stats(struct soap *soap, size_t *stat_get, size_t *stat_post, size_t *stat_fail, size_t **hist_min, size_t **hist_hour, size_t **hist_day);
#ifdef __cplusplus
}
#endif
#endif
-368
View File
@@ -1,368 +0,0 @@
/*
httppost.c
gSOAP HTTP POST/PUT/DELETE plugin for SOAP and non-SOAP payloads.
See instructions below.
Revisions:
register multiple POST content handlers, each for a content type
Note: multipart/related and multipart/form-data are already handled in gSOAP.
gSOAP XML Web services tools
Copyright (C) 2000-2018, Robert van Engelen, Genivia, Inc. All Rights Reserved.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2018 Robert A. van Engelen, Genivia inc. All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
[email protected] / [email protected]
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
Compile & link with stand-alone gSOAP server.
Usage (server side):
Define a NULL-terminated array of type-handler pairs, each with a media
type and a the handler function:
struct http_post_handlers my_handlers[] = {
{ "application/json", json_post_handler },
{ "image/jpg", jpeg_post_handler },
{ "text/html", html_post_handler },
{ "POST", generic_POST_handler },
{ "PUT", generic_PUT_handler },
{ "PATCH", generic_PATCH_handler },
{ "DELETE", generic_DELETE_handler },
{ NULL }
};
A `generic_POST_handler`, when specified with a `"POST"` key entry in
the table, takes priority over `soap_serve()` if no `SOAPAction` HTTP
header is included in the message. This means that SOAP/XML messages
without a `SOAPAction` header will not be processed by `soap_serve()`!
Note that `*` and `-` can be used as wildcards to match any text and
any character, respectively:
{ "image*", image_post_handler },
{ "text*", text_post_handler },
{ "text/---", three_char_type_text_handler },
In the above, to be more accurate, we should use a slash / between
image and the wildcard * (which is not shown in the table above due to
compilers throwing a fit at the / and * combo in this comment block).
It is possible to specify other paramters that must match:
{ "text/html; charset=utf-8", html_post_handler },
Media types may have optional parameters after `;` such as `charset`
and `boundary`. These parameters can be matched by the media type
patterns in the table. Patterns that are more specific must precede
patterns that are less specific in the table. For example,
`"text/xml;*charset=utf-8*"` must precede `"text/xml"` which must
precede `"text*"`. Note that `"text/xml"` also matches any parameters
of the media type of the message reveived, such as `"text/xml;
charset=utf-8"` (only since gSOAP version 2.8.75).
Each handler is a function that takes the soap context as a parameter
and returns SOAP_OK or an error code.
Register the plugin and the handlers:
struct soap soap;
soap_init(&soap);
soap_register_plugin_arg(&soap, http_post, my_handlers);
...
... = soap_copy(&soap); // copies plugin too but not its data: plugin data is shared since fcopy is not set
...
soap_done(&soap); // delete plugin (calls plugin->fdelete)
A POST handler function is triggered by the media type in the
http_post_handlers table. Use http_http_get_body() as below to retrieve
HTTP POST body data:
int image_post_handler(struct soap *soap)
{
const char *buf;
size_t len;
// if necessary, check type in soap->http_content
if (soap->http_content && soap_tag_cmp(soap->http_content, "image/gif"))
return 404;
buf = soap_http_get_body(soap, &len);
if (!buf)
return soap->error;
soap_end_recv(soap);
... // process image in buf[0..len-1]
// reply with empty HTTP OK response:
return soap_send_empty_response(soap, SOAP_OK);
}
This function should also produce a valid HTTP response, for example:
if (we want to return HTML)
{
if (soap_response(soap, SOAP_HTML) // use this to return HTML...
|| soap_send(soap, "<HTML>...</HTML>"); // example HTML
|| ...
|| soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
else
{
soap->http_content = "image/jpeg"; // a jpeg image
if (soap_response(soap, SOAP_FILE) // SOAP_FILE sets custom http content
|| soap_send_raw(soap, ..., ...);
|| ...
|| soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
The soap_closesock() call only closes the connection when it shoud not
be kept alive. This function is called automatically after the handler
returns. There is no harm in calling this function more than once.
The soap_send(soap, char*) and soap_send_raw(soap, char*, size_t) can
be used to return content from server.
The soap_response(soap, SOAP_FILE) call returns a HTTP 200 OK response
with the HTTP content-type header set to soap->http_content. To return
a http error status code use soap_response(soap, SOAP_FILE + status)
with status between 200 and 599 or 0.
Usage (client side):
char *buf; // to hold the HTTP response body data
size_t len;
...
if (soap_post_connect(soap, "URL", "SOAP action or NULL", "media type")
|| soap_send(soap, ...)
|| soap_end_send(soap))
... // error
if (soap_begin_recv(&soap)
|| soap_http_body(&soap, &buf, &len)
|| soap_end_recv(&soap))
... // error
... // use buf[0..len-1]
soap_closesock(soap); // close, but keep open only with HTTP keep-alive
soap_end(soap); // also deletes buf content
The soap_send(soap, char*) and soap_send_raw(soap, char*, size_t) can
be used to send content to the server as shown above.
*/
#include "httppost.h"
#ifdef __cplusplus
extern "C" {
#endif
const char http_post_id[] = HTTP_POST_ID;
static int http_post_init(struct soap *soap, struct http_post_data *data, struct http_post_handlers *handlers);
static void http_post_delete(struct soap *soap, struct soap_plugin *p);
static int http_post_parse_header(struct soap *soap, const char*, const char*);
static http_handler_t http_lookup_handler(struct soap *soap, const char *type, struct http_post_data *data);
static int http_fput(struct soap *soap);
static int http_fpatch(struct soap *soap);
static int http_fdel(struct soap *soap);
int http_post(struct soap *soap, struct soap_plugin *p, void *arg)
{
p->id = http_post_id;
p->data = (void*)SOAP_MALLOC(soap, sizeof(struct http_post_data));
p->fdelete = http_post_delete;
if (!p->data)
return SOAP_EOM;
if (http_post_init(soap, (struct http_post_data*)p->data, (struct http_post_handlers *)arg))
{
SOAP_FREE(soap, p->data); /* error: could not init */
return SOAP_EOM; /* return error */
}
return SOAP_OK;
}
static int http_post_init(struct soap *soap, struct http_post_data *data, struct http_post_handlers *handlers)
{
data->fparsehdr = soap->fparsehdr; /* save old HTTP header parser callback */
soap->fparsehdr = http_post_parse_header; /* replace HTTP header parser callback with ours */
data->fput = soap->fput;
soap->fput = http_fput;
data->fpatch = soap->fpatch;
soap->fpatch = http_fpatch;
data->fdel = soap->fdel;
soap->fdel = http_fdel;
data->handlers = handlers;
return SOAP_OK;
}
static void http_post_delete(struct soap *soap, struct soap_plugin *p)
{
soap->fparsehdr = ((struct http_post_data*)p->data)->fparsehdr;
soap->fput = ((struct http_post_data*)p->data)->fput;
soap->fpatch = ((struct http_post_data*)p->data)->fpatch;
soap->fdel = ((struct http_post_data*)p->data)->fdel;
SOAP_FREE(soap, p->data); /* free allocated plugin data (this function is not called for shared plugin data, but only when the final soap_done() is invoked on the original soap struct) */
}
static int http_post_parse_header(struct soap *soap, const char *key, const char *val)
{
struct http_post_data *data = (struct http_post_data*)soap_lookup_plugin(soap, http_post_id);
if (!data)
return SOAP_PLUGIN_ERROR;
if (data->fparsehdr(soap, key, val)) /* parse HTTP header */
return soap->error;
if (!soap_tag_cmp(key, "Content-Type")) /* check content type */
soap->fform = http_lookup_handler(soap, val, data);
if (!soap->fform)
soap->fform = http_lookup_handler(soap, "POST", data);
return soap->error;
}
static http_handler_t http_lookup_handler(struct soap *soap, const char *type, struct http_post_data *data)
{
struct http_post_handlers *p;
const char *params = strchr(type, ';');
char temp[SOAP_HDRLEN];
(void)soap;
if (params)
{
size_t n = params - type;
soap_strncpy(temp, sizeof(temp), type, n);
temp[n] = '\0';
}
for (p = data->handlers; p && p->type; p++)
{
if (params)
{
if (strchr(p->type, ';'))
{
if (!soap_tag_cmp(type, p->type))
break;
}
else if (!soap_tag_cmp(temp, p->type))
{
break;
}
}
else if (!soap_tag_cmp(type, p->type))
{
break;
}
}
if (p && p->type)
{
DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Found HTTP POST plugin handler for '%s'\n", type));
return p->handler;
}
return NULL;
}
static int http_fput(struct soap *soap)
{
int (*fform)(struct soap*);
struct http_post_data *data = (struct http_post_data*)soap_lookup_plugin(soap, http_post_id);
if (!data)
return SOAP_PLUGIN_ERROR;
fform = http_lookup_handler(soap, "PUT", data);
if (fform)
return fform(soap);
return data->fput(soap);
}
static int http_fpatch(struct soap *soap)
{
int (*fform)(struct soap*);
struct http_post_data *data = (struct http_post_data*)soap_lookup_plugin(soap, http_post_id);
if (!data)
return SOAP_PLUGIN_ERROR;
fform = http_lookup_handler(soap, "PATCH", data);
if (fform)
return fform(soap);
return data->fpatch(soap);
}
static int http_fdel(struct soap *soap)
{
int (*fform)(struct soap*);
struct http_post_data *data = (struct http_post_data*)soap_lookup_plugin(soap, http_post_id);
if (!data)
return SOAP_PLUGIN_ERROR;
fform = http_lookup_handler(soap, "DELETE", data);
if (fform)
return fform(soap);
return data->fdel(soap);
}
/******************************************************************************/
/* call soap_http_get_body to receive HTTP body and set buf and len */
int soap_http_body(struct soap *soap, char **buf, size_t *len)
{
*buf = soap_http_get_body(soap, len);
if (*buf)
return SOAP_OK;
return soap->error;
}
/******************************************************************************/
/* deprecated: use soap_POST instead */
int soap_post_connect(struct soap *soap, const char *endpoint, const char *action, const char *type)
{
return soap_POST(soap, endpoint, action, type);
}
/* deprecated: use soap_PUT instead */
int soap_put_connect(struct soap *soap, const char *endpoint, const char *action, const char *type)
{
return soap_PUT(soap, endpoint, action, type);
}
/* deprecated: use soap_DELETE instead */
int soap_delete_connect(struct soap *soap, const char *endpoint)
{
return soap_DELETE(soap, endpoint);
}
/******************************************************************************/
#ifdef __cplusplus
}
#endif
-101
View File
@@ -1,101 +0,0 @@
/*
httppost.h
gSOAP HTTP POST plugin for non-SOAP payloads.
See httppost.c for instructions.
Revisions:
register multiple POST content handlers, each for a content type
gSOAP XML Web services tools
Copyright (C) 2000-2018, Robert van Engelen, Genivia, Inc. All Rights Reserved.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2004 Robert A. van Engelen, Genivia inc. All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
[email protected] / [email protected]
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
*/
#ifndef HTTPPOST_H
#define HTTPPOST_H
#include "stdsoap2.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HTTP_POST_ID "SOAP-HTTP-POST/2.2" /* plugin identification */
extern const char http_post_id[];
typedef int (*http_handler_t)(struct soap*);
struct http_post_handlers
{
const char *type;
http_handler_t handler;
};
/* This is the local plugin data shared among all copies of the soap struct: */
struct http_post_data
{
int (*fparsehdr)(struct soap*, const char*, const char*); /* to save and call the internal HTTP header parser */
int (*fput)(struct soap*); /* to save */
int (*fpatch)(struct soap*); /* to save */
int (*fdel)(struct soap*); /* to save */
struct http_post_handlers *handlers; /* the server-side POST content type handlers */
};
/* the http post plugin, note: argument should be a table of type-handler pairs */
int http_post(struct soap*, struct soap_plugin*, void*);
/* deprecated: use soap_POST instead */
int soap_post_connect(struct soap*, const char *endpoint, const char *action, const char *type);
/* deprecated: use soap_PUT instead */
int soap_put_connect(struct soap*, const char *endpoint, const char *action, const char *type);
/* deprecated: use soap_DELETE instead */
int soap_delete_connect(struct soap*, const char *endpoint);
/* deprecated: use soap_get_http_body instead */
int soap_http_body(struct soap*, char **buf, size_t *len);
#ifdef __cplusplus
}
#endif
#endif