2

我使用 Python 的 SimpleHTTPServer 在我的笔记本电脑上设置了一个临时服务器,地址为 127.0.0.1:8000。我编写了一个小型 C 程序,它试图连接到服务器并查看那里的文件,d.txt. 但是,我的程序没有正确连接。HttpSendRequestA抛出ERROR_SXS_KEY_NOT_FOUND (00002EE7),但问题更高。

#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;
}
4

0 回答 0