char* form(struct soap *soap) { char *s = NULL; /* It is unlikely chunked and/or compressed POST forms are sent by browsers, but we need to handle them */ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK #ifdef WITH_ZLIB || soap->zlib_in != SOAP_ZLIB_NONE #endif ) { soap_wchar c = EOF; soap->labidx = 0; if (soap_append_lab(soap, "?", 1)) return NULL; do { register size_t k; if (soap_append_lab(soap, NULL, 0)) return NULL; s = soap->labbuf + soap->labidx; k = soap->lablen - soap->labidx; soap->labidx = soap->lablen; while (k--) { if ((c = soap_getchar(soap)) == (int)EOF) break; *s++ = c; } } while (c != (int)EOF); *s = '\0'; s = soap->labbuf; } else { if (soap->length) { s = (char*)soap_malloc(soap, soap->length + 2); if (s) { char *t = s; size_t i; *t++ = '?'; for (i = soap->length; i; i--) { soap_wchar c; if ((c = soap_getchar(soap)) == (int)EOF) { soap->error = SOAP_EOF; return NULL; } *t++ = c; } *t = '\0'; } } } soap_end_recv(soap); return s; }
int soap_http_body(struct soap *soap, char **buf, size_t *len) { char *s = *buf = NULL; *len = 0; /* It is unlikely chunked and/or compressed POST messages are sent by browsers, but we need to handle them */ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK #ifdef WITH_ZLIB || soap->zlib_in != SOAP_ZLIB_NONE #endif ) { register size_t k; soap_wchar c = EOF; soap->labidx = 0; do { if (soap_append_lab(soap, NULL, 0)) return soap->error; s = soap->labbuf + soap->labidx; k = soap->lablen - soap->labidx; soap->labidx = soap->lablen; while (k--) { if ((c = soap_getchar(soap)) == (int)EOF) break; *s++ = c; } } while (c != (int)EOF); *len = soap->lablen - k - 1; *buf = (char*)soap_malloc(soap, *len + 1); memcpy(*buf, soap->labbuf, *len + 1); } else { if (soap->length) { s = (char*)soap_malloc(soap, soap->length + 1); if (s) { char *t = s; size_t i; for (i = soap->length; i; i--) { soap_wchar c; if ((c = soap_getchar(soap)) == (int)EOF) return soap->error = SOAP_EOF; *t++ = c; } *t = '\0'; } } *buf = s; *len = soap->length; } return soap_end_recv(soap); }