1
0
mirror of https://github.com/wg/wrk synced 2025-01-08 06:52:55 +08:00

copy request string from lua stack

This commit is contained in:
Will 2014-08-05 21:49:25 +09:00
parent 0c64376d09
commit 88aa6c5237
2 changed files with 5 additions and 3 deletions

View File

@ -77,7 +77,9 @@ void script_init(lua_State *L, char *script, int argc, char **argv) {
void script_request(lua_State *L, char **buf, size_t *len) {
lua_getglobal(L, "request");
lua_call(L, 0, 1);
*buf = (char *) lua_tolstring(L, 1, len);
const char *str = lua_tolstring(L, 1, len);
*buf = realloc(*buf, *len);
memcpy(*buf, str, *len);
lua_pop(L, 1);
}
@ -189,7 +191,7 @@ size_t script_verify_request(lua_State *L) {
.on_message_complete = verify_request
};
http_parser parser;
char *request;
char *request = NULL;
size_t len, count = 0;
script_request(L, &request, &len);

View File

@ -14,7 +14,7 @@
#include "script.h"
#include "http_parser.h"
#define VERSION "3.1.0"
#define VERSION "3.1.1"
#define RECVBUF 8192
#define SAMPLES 100000000