From fe1e1200c1541676e6b8402b7972a16105a76a63 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 22 Aug 2013 23:11:49 +0000 Subject: http: remove Status: header from all responses This was inherited from a server which needed to deal with some broken clients, MogileFS does not have this problem. Neither Perlbal nor nginx set this response header, either, so lets save ourselves a few bytes. --- http.c | 2 -- http_get.c | 3 --- test/http.rb | 2 +- test/http_chunked_put.rb | 8 -------- test/http_put.rb | 2 -- test/http_put_slow.rb | 1 - 6 files changed, 1 insertion(+), 17 deletions(-) diff --git a/http.c b/http.c index 2f3b29b..3ec62a6 100644 --- a/http.c +++ b/http.c @@ -480,8 +480,6 @@ void mog_http_resp0(struct mog_fd *mfd, struct iovec *status, bool alive) #define CPY(str) mempcpy(dst, (str),(sizeof(str)-1)) dst = CPY("HTTP/1.1 "); dst = mempcpy(dst, status->iov_base, status->iov_len); - dst = CPY("\r\nStatus: "); - dst = mempcpy(dst, status->iov_base, status->iov_len); dst = CPY("\r\nDate: "); now = mog_now(); dst = mempcpy(dst, now->httpdate, sizeof(now->httpdate)-1); diff --git a/http_get.c b/http_get.c index 252ec5c..98735f0 100644 --- a/http_get.c +++ b/http_get.c @@ -112,7 +112,6 @@ static off_t http_get_resp_hdr(struct mog_fd *mfd, struct stat *sb) rc = snprintf(buf, len, "HTTP/1.1 206 Partial Content\r\n" - "Status: 206 Partial Content\r\n" "Date: %s\r\n" "Last-Modified: %s\r\n" "Content-Length: %lld\r\n" @@ -131,7 +130,6 @@ resp_200: count = (long long)sb->st_size; rc = snprintf(buf, len, "HTTP/1.1 200 OK\r\n" - "Status: 200 OK\r\n" "Date: %s\r\n" "Last-Modified: %s\r\n" "Content-Length: %lld\r\n" @@ -158,7 +156,6 @@ bad_range: } rc = snprintf(buf, len, "HTTP/1.1 " ERR416 "\r\n" - "Status: " ERR416 "\r\n" "Date: %s\r\n" "Content-Length: 0\r\n" "Content-Type: text/plain\r\n" diff --git a/test/http.rb b/test/http.rb index b296ffa..c847046 100644 --- a/test/http.rb +++ b/test/http.rb @@ -184,7 +184,7 @@ class TestHTTP < Test::Unit::TestCase nr.times { @client.write(req2) } @client.write("GET /dev666/test HTTP/1.0\r\n\r\n") all = thr.value - assert_equal((nr * 2) + 1, all.split(/\r\n/).grep(/Status:/).size); + assert_equal((nr * 2) + 1, all.split(/\r\n/).grep(%r{^HTTP\/}).size); end def test_garbage diff --git a/test/http_chunked_put.rb b/test/http_chunked_put.rb index 817ced7..8f07c85 100644 --- a/test/http_chunked_put.rb +++ b/test/http_chunked_put.rb @@ -86,7 +86,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase def edge_finder(suf) expect = "HTTP/1.1 200 OK\r\n" \ - "Status: 200 OK\r\n" \ "Date: #{EPOCH}\r\n" \ "Last-Modified: #{EPOCH}\r\n" \ "Content-Length: 5\r\n" \ @@ -125,7 +124,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase def check_abcde(msg=nil) expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ @@ -219,7 +217,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase t_yield @client.write(moar) expect = "HTTP/1.1 200 OK\r\n" \ - "Status: 200 OK\r\n" \ "Date: #{EPOCH}\r\n" \ "Last-Modified: #{EPOCH}\r\n" \ "Content-Length: 5\r\n" \ @@ -245,7 +242,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase check_abcde @client.write(more) expect = "HTTP/1.1 200 OK\r\n" \ - "Status: 200 OK\r\n" \ "Date: #{EPOCH}\r\n" \ "Last-Modified: #{EPOCH}\r\n" \ "Content-Length: 5\r\n" \ @@ -274,7 +270,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase t_yield @client.write(moar) expect = "HTTP/1.1 200 OK\r\n" \ - "Status: 200 OK\r\n" \ "Date: #{EPOCH}\r\n" \ "Last-Modified: #{EPOCH}\r\n" \ "Content-Length: 5\r\n" \ @@ -293,7 +288,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase "0\r\n\r\n" @client.write(req) expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ @@ -316,7 +310,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase end.join @client.write(req) expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ @@ -344,7 +337,6 @@ class TestHTTPChunkedPut < Test::Unit::TestCase end expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ diff --git a/test/http_put.rb b/test/http_put.rb index 537182c..5f1fea1 100644 --- a/test/http_put.rb +++ b/test/http_put.rb @@ -82,7 +82,6 @@ class TestHTTPPut < Test::Unit::TestCase "abcde" @client.write(req) expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ @@ -103,7 +102,6 @@ class TestHTTPPut < Test::Unit::TestCase end.join @client.write(req) expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ diff --git a/test/http_put_slow.rb b/test/http_put_slow.rb index 6e0cc6f..2b37b0f 100644 --- a/test/http_put_slow.rb +++ b/test/http_put_slow.rb @@ -72,7 +72,6 @@ class TestHTTPPutSlow < Test::Unit::TestCase "\r\n" @client.write(req) expect = "HTTP/1.1 201 Created\r\n" \ - "Status: 201 Created\r\n" \ "Date: #{EPOCH}\r\n" \ "Content-Length: 0\r\n" \ "Content-Type: text/plain\r\n" \ -- cgit v1.2.3-24-ge0c7