# Received: "" (no content received)

**URL:** <https://forum.codecrafters.io/t/received-no-content-received/11565>\
**Category:** Challenges\
**Tags:** challenge:http-server\
**Created:** [June 2, 2025, 4:23pm UTC](https://forum.codecrafters.io/t/received-no-content-received/11565 "2025-06-02T16:23:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguelBarreiro85](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/miguelbarreiro85/32/12305_2.png) [@miguelBarreiro85](https://forum.codecrafters.io/u/miguelBarreiro85)\
**Post date:** [June 2, 2025, 4:23pm UTC](https://forum.codecrafters.io/t/received-no-content-received/11565/1 "2025-06-02T16:23:40Z")

</div>

I’m stuck in the concurrent connections challenge

It works on my computer but not for the tests…  
I receive from the test this output:

Creating connection 2  
[tester::#EJ5] Sending first set of requests  
[tester::#EJ5] client-2: $ curl -v [http://localhost:4221/](http://localhost:4221/)  
[tester::#EJ5] client-2: \> GET / HTTP/1.1  
[tester::#EJ5] client-2: \> Host: localhost:4221  
[tester::#EJ5] client-2: \>  
[tester::#EJ5] client-2: Sent bytes: “GET / HTTP/1.1\r\nHost: localhost:4221\r\n\r\n”  
[your\_program] Receive a connection: /0:0:0:0:0:0:0:1  
[your\_program] worker started  
[tester::#EJ5] Failed to read response:  
[tester::#EJ5] Received: “” (no content received)  
[tester::#EJ5] ^ error  
[tester::#EJ5] Error: Expected: HTTP-version, Received: “”  
[tester::#EJ5] Test failed

and this is how i’m reading the request:

```
      InputStream in = this.socket.getInputStream();
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      int prev = -1, curr;
      //read target and method
      while (true) {
          curr = in.read(); //<- HERE is the problem it hangs a little then conncection is closed
          if (prev == '\r' && curr == '\n') {
              break;
          }
          buffer.write(curr);
          prev = curr;
      }

      String tmp = buffer.toString("UTF-8");
      this.method = tmp.split(" ")[0].trim();
      this.target = tmp.split(" ")[1].trim();

      System.out.println("Target: " + this.target);
      System.out.println("Method: " + this.method);
      buffer.reset();
      // Read the headers
      while (true) {
          curr = in.read();
          buffer.write(curr);
          if (buffer.size() >= 4) {
              byte[] last4 = buffer.toByteArray();
              int len = last4.length;
              if (last4[len - 1] == '\n' && last4[len - 2] == '\r' && last4[len - 3] == '\n'
                      && last4[len - 4] == '\r') {
                  break;
              }
          }
      }

      // Read the Headers to the MAP
      String headers = buffer.toString("UTF-8");
      String[] headerLines = headers.split("\r\n");
      for (String header : headerLines) {
          if (header.contains(":")) {
              String k = header.split(":")[0].trim();
              String v = header.split(":")[1].trim();
              this.headers.put(k, v);
          }
      }
      System.out.println("HEADERS: " + this.headers.toString());

      // READ the body
      int cl = 0;
      if (this.headers.containsKey("Content-Length")) {
          cl = Integer.parseInt(this.headers.get("Content-Length"));
      }
      this.body = new byte[cl];
      int bytesRead = 0;
      while (bytesRead < cl) {
          int res = in.read(this.body, bytesRead, cl - bytesRead);
          if (res == -1)
              break;
          bytesRead += res;
      }

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [June 2, 2025, 9:04pm UTC](https://forum.codecrafters.io/t/received-no-content-received/11565/3 "2025-06-02T21:04:40Z")

</div>

Hey @miguelBarreiro85, there might be a few things at play here.

The main issue is that `readLine`, which is intended to be run concurrently, has been placed inside the non-concurrent constructor `Worker` instead of the concurrent `run`.

Let me know if you’d like further clarification!

---

<div class="post-metadata">

**Author:** ![miguelBarreiro85](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/miguelbarreiro85/32/12305_2.png) [@miguelBarreiro85](https://forum.codecrafters.io/u/miguelBarreiro85)\
**Post date:** [June 3, 2025, 8:35pm UTC](https://forum.codecrafters.io/t/received-no-content-received/11565/4 "2025-06-03T20:35:11Z")

</div>

Thanks andy that was the problem 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [June 8, 2025, 8:35pm UTC](https://forum.codecrafters.io/t/received-no-content-received/11565/5 "2025-06-08T20:35:13Z")

</div>

Closed on June 8, 2025, 8:35pm UTC

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