Fix bug in client and change the Makefiles
This commit is contained in:
parent
36495526b5
commit
712e3910ad
@ -28,4 +28,4 @@ clean:
|
|||||||
$(RM) *.tgz
|
$(RM) *.tgz
|
||||||
|
|
||||||
package:
|
package:
|
||||||
tar -cvzf server.tgz $(TARGET_1).c $(TARGET_2).c shared public Makefile
|
tar -cvzf http.tgz $(TARGET_1).c $(TARGET_2).c shared public Makefile
|
||||||
|
@ -82,15 +82,15 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
char *base_url = strstr(url, "http://") + 7; //< the base url starts after http://
|
char *base_url = strstr(url, "http://") + 7; //< the base url starts after http://
|
||||||
|
|
||||||
const char *path = strstr(base_url, "/");
|
char *path = malloc(strlen(base_url) + 1);
|
||||||
|
strcpy(path, base_url); //< Copying so that strtok() doesn't change it
|
||||||
|
path = strstr(path, "/");
|
||||||
if(path == NULL) path = "/"; //< Set the root path if there is none
|
if(path == NULL) path = "/"; //< Set the root path if there is none
|
||||||
|
|
||||||
const char *hostname = strtok(base_url, ";/?:@=&"); //< Get the FQDN of the remote
|
const char *hostname = strtok(base_url, ";/?:@=&"); //< Get the FQDN of the remote
|
||||||
|
|
||||||
struct addrinfo* config = get_host_info(hostname, port); //< Check if the address is resolvable
|
struct addrinfo* config = get_host_info(hostname, port); //< Check if the address is resolvable
|
||||||
|
|
||||||
char header[strlen(base_url) + 100]; //< Create a variable to store the header
|
char header[strlen(base_url) + 100]; //< Create a variable to store the header
|
||||||
|
|
||||||
snprintf(header, sizeof header, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", path, hostname); //< Build the header
|
snprintf(header, sizeof header, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", path, hostname); //< Build the header
|
||||||
|
|
||||||
int sockfd = create_socket(config);
|
int sockfd = create_socket(config);
|
||||||
|
@ -12,3 +12,7 @@ install:
|
|||||||
clean:
|
clean:
|
||||||
$(RM) $(TARGET).o
|
$(RM) $(TARGET).o
|
||||||
$(RM) $(TARGET)
|
$(RM) $(TARGET)
|
||||||
|
$(RM) *.tgz
|
||||||
|
|
||||||
|
package:
|
||||||
|
tar -cvzf mygrep.tgz $(TARGET).c Makefile
|
||||||
|
Reference in New Issue
Block a user