I’m stuck on stage 8.
I’ve tried to debug my code in many ways, but no matter what I do I can see that issue must be on the client side.
Here are my logs with the request which I should process:
[stage-8] Sending request: (Messages with >>> prefix are part of this log)
[stage-8] >>> POST /files/mango_orange_strawberry_grape HTTP/1.1
[stage-8] >>> Host: localhost:4221
[stage-8] >>> User-Agent: Go-http-client/1.1
[stage-8] >>> Content-Length: 59
[stage-8] >>> Accept-Encoding: gzip
[stage-8] >>>
[stage-8] >>> banana banana grape pear orange strawberry pineapple banana
...
[your_program] Debug line1 Accept-Encoding: gzip
[your_program] Debug line1
[stage-8] Failed to connect to server, err: 'Post "http://localhost:4221/files/mango_orange_strawberry_grape": context deadline exceeded (Client.Timeout exceeded while awaiting headers)'
[stage-8] Test failed
So what is exactly happening? I can read headers and one line after them (“Debug line1 …”) and then request processing freezes (even in my test in VSC stops for 2-3 seconds, so it’s clear it’s waiting for input). I tried below ways to debug:
- while loop to read headers and stop when empty line arrives, then start new while loop to read body
- while loop that ignores line content and simply reads 10 lines no matter what (it should read 4 lines of headers, one empty line, one body line and only then possibly crash)
- while look that reads headers, stops when empty line arrives, then prints some random stuff, then does some calculations and prints it and only then starts second while loop to read body
- same like previous, but it doesn’t have second while loop and instead tries to read just one more line (which sould be body)
In each case I output each line to console to see what was read at the time when it arrives and every single time timeout error comes just before body line should be read. I spent couple of hours on this and I give up… Any help is appreviated.