2

I've set up a temporary server on my laptop at 127.0.0.1:8000 using Python's SimpleHTTPServer. I've written a small C program that is attempting to connect to the server and look at a file there, d.txt. However, my program doesn't properly connect. HttpSendRequestA throws ERROR_SXS_KEY_NOT_FOUND (00002EE7) but the problem is higher up.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <wininet.h>

int main(void) {

  HINTERNET* openHandle;
  openHandle = InternetOpenA("Windows+NT+5.1",0, NULL, NULL, 0);

  HINTERNET* connectHandle;
  connectHandle = InternetConnectA(openHandle,"127.0.0.1",8000,NULL,NULL,0,3,0);

  HINTERNET* httpHandle;
  char* arr[] = {"text//*", NULL};
  httpHandle = HttpOpenRequestA(connectHandle, "GET", "d.txt", "HTTP/1.1", 0,
               arr,0,0);

  int result2;
  result2 = HttpSendRequestA(httpHandle, 0,0,0,0);
  printf("%d",result2);

  return EXIT_SUCCESS;
}
Kara
  • 6,115
  • 16
  • 50
  • 57
Daniel
  • 2,435
  • 5
  • 26
  • 40

0 Answers0