Added testing code for retrieving HTTP response

This commit is contained in:
2023-03-10 13:00:38 -06:00
parent f8b64d9afa
commit 5b61ab14c0

11
main.c
View File

@@ -79,12 +79,17 @@ void testFunc(Widget w, XtPointer client_data, XmPushButtonCallbackStruct *callb
and make the connection for us. It returns the socket, so that the HTTP request can be made. and make the connection for us. It returns the socket, so that the HTTP request can be made.
First parameter is IP version - set to -1 because we don't know yet if the address is IPv4 or IPv6. */ First parameter is IP version - set to -1 because we don't know yet if the address is IPv4 or IPv6. */
char* request = "GET /~fdc/sample.html HTTP/1.1\nHost: www.columbia.edu\n\n"
char* response = malloc(sizeof(char) * 5000);
struct sockaddr* address_struct; struct sockaddr* address_struct;
int remote_socket = create_remote(-1,'T',url_to_hostname(url),port,address_struct); int remote_socket = create_remote(-1,'T',url_to_hostname(url),port,address_struct);
XmHTMLTextSetString(result_widget,""); send(remote_socket,request,strlen(request),0);
recv(remote_socket,response,sizeof(response),0);
XmHTMLTextSetString(result_widget,response);
// printf("%d\n",val); // printf("%d\n",val);
// exit(2); // exit(2);
} }