diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2015-01-29 21:53:08 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2015-01-30 17:04:30 +0100 |
commit | 50802193c013bf79411111cf393b3aafa5ad2dc5 (patch) | |
tree | a624d33af602e8a86757638c5ad32095e1ae845f | |
parent | 319840b83b70b49705928687dcbd40653709e305 (diff) |
geoip: Fix update failing
I have no enough arguments for this fix but it
fixes the failing of geoip updating.
Seems "shutdown(..)" closes socket too early.
So shutdown(...) is removed and added "Connection: close"
http header which says http server to close connection after
response will be sent.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | geoip.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -162,7 +162,9 @@ static int geoip_get_database(const char *host, int which) size_t lenl = strlen("Content-Length: "); size_t lent = strlen("HTTP/1.1 200 OK"); size_t lenc = strlen("\r\n\r\n"); - + const char *http_req_fmt = "GET %s%s HTTP/1.1\n" + "Connection: close\n" + "Host: %s\r\n\r\n"; again: found = good = 0; ptr = NULL; @@ -172,7 +174,7 @@ again: if (sock < 0) return -EIO; - slprintf(raw, sizeof(raw), "GET %s%s HTTP/1.1\nHost: %s\r\n\r\n", + slprintf(raw, sizeof(raw), http_req_fmt, retry ? files[which].possible_prefix : "", files[which].remote, host); @@ -182,8 +184,6 @@ again: return -EIO; } - shutdown(sock, SHUT_WR); - slprintf(zfile, sizeof(zfile), "%s.gz", files[which].local); fd = open_or_die_m(zfile, O_WRONLY | O_CREAT | O_TRUNC, DEFFILEMODE); @@ -238,7 +238,7 @@ again: ptr = raw; len = ret; - } while(ret > 0); + } while (ret > 0); printf("\n"); |