title: Make a Http Request With Sockets
body: <p>I have trying to make a GET/ POST request. GET request for now. I am able to establish connection but the response i get is never 200 OK. Here is the code</p>
  
  <pre><code>   int socketFD;
      struct sockaddr_in myaddr;
      //    struct sockaddr_in hints;
      socketFD = socket(AF_INET, SOCK_STREAM, 0);
      if (socketFD == -1) {
          NSLog(@"Error in making socket");
      }      
      myaddr.sin_port = htons(80);
      memset(&amp;myaddr.sin_zero, '\0', 8);
  
  
      char *sendbug = "GET 173.194.66.99 HTTP/1.0\r\n\r\n";
  
  
      struct sockaddr_in dest,their_addr;
      //    struct addrinfo *res;
      struct sockaddr sockAddrToDisplay;
  
      dest.sin_family = AF_INET;
      dest.sin_port = htons(80);
      NSLog(@"%s",sendbug);
      dest.sin_addr.s_addr = inet_addr("173.194.66.99"); // IP for google
  
  
      int connectResult =    connect(socketFD, (struct sockaddr *)&amp;dest, sizeof(struct sockaddr));
  
      if (connectResult == -1) {
          NSLog(@"Error connecting");
      }
  
      int sendResult =   sendto(socketFD, sendbug, strlen(sendbug), 0, (struct sockaddr *)&amp;dest, sizeof(struct sockaddr));
  
      if (sendResult == -1) {
          NSLog(@"Sendind failed");
      }
  
      //    int peerResult =    getpeername(socketFD, (struct sockaddr *)&amp;dest,(socklen_t *) sizeof(struct sockaddr));
  
  
      struct addrinfo hints, *res;
      int sockfd;
      int byte_count;
      socklen_t fromlen;
      struct sockaddr_storage addr;
      char buf[512];
      char ipstr[INET6_ADDRSTRLEN];
  
  
      fromlen = sizeof addr;
      byte_count = recvfrom(socketFD, buf, sizeof buf, 0,(struct sockaddr *) &amp;addr, &amp;fromlen);
  
      NSLog(@"%s",buf);
  </code></pre>
  
  <p>And the response. I need some help where i am doing wrong and also, how i can make a http POST request. thx in advance fellows</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;title&gt;400 Bad Request&lt;/title&gt;&lt;/head&gt;
  &lt;body bgcolor="white"&gt;
  &lt;center&gt;&lt;h1&gt;400 Bad Request&lt;/h1&gt;&lt;/center&gt;
  &lt;hr&gt;&lt;center&gt;nginx/1.3.7&lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  ∑¥ëXnr
  </code></pre>