Posts

Showing posts from September, 2023

How to make HTTP Server wait to read input from socket to test connection timeout

 To test HTTP server or proxy is closing HTTP connection on configured timeout when client browser or application is taking longer to send complete HTTP request. In this case, HTTP Server (tested with WildFly) waits in reading from socket. This works in case of POST request by specifying content length header but write only lesser bytes to socket than specified in content length header. Option 1: https://stackoverflow.com/a/53695968 exec 88<>/dev/tcp/192.168.1.10/8080 echo -e 'POST /api/test/ HTTP/1.1\nHost: 192.168.1.10:8080\nAccept: */*\nContent-Type: application/json\nContent-Length: 200\n\n{ "id": "100"} ] }\n\n' >&88 sed 's/<[^>]*>/ /g' <&88 Option 2: Used netcat in Linux. Note that there is a line between Content-Length: 200 and JSON. This is needed for compliance with HTTP spec. netcat -v -v 192.168.1.10 8080 POST /api/test HTTP/1.1 User-Agent: curl/7.29.0 Host: 192.168.1.10:8080 Accept: */* Content-Type: applicati...