diff options
Diffstat (limited to 'src/response.c')
| -rw-r--r-- | src/response.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/response.c b/src/response.c new file mode 100644 index 0000000..1000da6 --- /dev/null +++ b/src/response.c @@ -0,0 +1,32 @@ +#include "libhttpc.h" + +#include <stddef.h> +#include <string.h> + + +char *LibHTTPC_dumpResponse(struct LibHTTPC_Response *response, char *buf, size_t buf_len) +{ + if (!response->version || !response->status || !response->phrase) + return NULL; + +#define append(X) strncat(buf, (X), buf_len - strlen(buf)) + append(response->version); + append(""); + append(response->status); + append(" "); + append(response->phrase); + append("\r\n"); + for (size_t i = 0; i < response->header_count; ++i) + { + append(response->header_names[i]); + append(": "); + append(response->header_values[i]); + append("\r\n"); + } + append("\r\n"); + if (response->body) + append(response->body); +#undef append + + return NULL; +} |