Search This Blog

Tuesday, October 22, 2019

C# Controller - accept any json in POST (not typed)

in case you want to get any json string (not typed) , you can try the next code snippets

             [HttpPost]
        public ActionResult Bot(string request)
        {
            Request.InputStream.Position = 0;
            var input = new StreamReader(Request.InputStream).ReadToEnd();

            JObject json = JObject.Parse(input);
           ...........
       }

Tuesday, October 15, 2019

Gor - GoReplay - capturing and replaying live HTTP traffic

Gor is an open-source tool for capturing and replaying live HTTP traffic into a test environment in order to continuously test your system with real data. It can be used to increase confidence in code deployments, configuration changes and infrastructure changes.

usefull links 
https://github.com/buger/goreplay/wiki/Running-on-Windows



be aware if you listen to port 8000 you must have a live server on this port up and running.

on windows i get failed to listen on the localhost ( some loopback issue on the netwrok) , there are some post/articles about this issue  e.g. https://github.com/buger/goreplay/issues/440

but non- of them help me to capture from local host.
so i access my web server from remote and its work perfectly .
mean:
gor is running from the webserver machine e.g MyServer , and connect to port e.g 7001.
i access to this webserver from remote machine via url , e.g. http://MyServer :7001

starter command
-- will replay only POST method from the file requests.gor
goreplay.exe --input-file requests.gor --output-http="http://localhost:7001"  --http-allow-method POST

-- replay all request
goreplay.exe --input-file new_contact_0.gor --output-http="http://hlvm-yanivt:7001" 

--replay all request and log response 
goreplay.exe --input-file new_contact_0.gor --output-http="http://hlvm-yanivt:7001" --output-http-track-response --input-raw-track-response --output-file=new_contact_play.gor

--start record and log response
goreplay.exe --input-raw :7001 --output-stdout  --output-http-track-response --input-raw-track-response --output-file=requests.gor 


enjoy
Yaniv Tzanany