Write binary data to socket

I’m stuck on Stage #13.

I am trying to write the headers first in a socket.write(), since they are a string and then sending the gzipped bytes in another socket.write(). I see that content-encoding header is present, but tests fails saying that it isnt there. I think its because the header string is also converted to binary.

Here are my logs:

remote: [tester::#CR8] Received bytes: "HTTP/1.1 200 OK\r\n\r\n"
remote: [tester::#CR8] < HTTP/1.1 200 OK
remote: [tester::#CR8] < 
remote: [tester::#CR8] Received response with 200 status code
remote: [tester::#CR8] Expected "Content-Encoding" header to be present
remote: [tester::#CR8] Test failed```

And here's a snippet of my code: 

```typescript
            const finalResponse = composeResponse(response.response);
            socket.write(finalResponse);
            console.log("Here " + finalResponse);
            socket.write(response.response.messagebytes);```

finalResponse is getting logged as

HTTP/1.1 200 OK
remote: [your_program]
remote: [your_program] Content-Type:text/plain
remote: [your_program] Content-Encoding:gzip
remote: [your_program]
remote: [your_program] Content-Length:30

NVM, resolved the issue looking at other solutions, there was a missing CLRF which was messing up the format.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.