summaryrefslogtreecommitdiff
path: root/test/etap/140-attachment-comp.t
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2011-09-29 23:34:40 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2011-09-29 23:34:40 +0000
commit1285cd95c8fe351991218f886bbfe28d9a9a3b09 (patch)
treea62af53acc1fb9be4e943ab1935e6fa92889863f /test/etap/140-attachment-comp.t
parent89a5c28775f24f2706f443c76afa3edf9df78ce4 (diff)
Remove usage of http module from etap tests
This module is deprecated in OTP R15, which is going to be released by the end of this year. The etap tests now use ibrowse instead. This is a backport of revision 1177459 from trunk. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1177463 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/etap/140-attachment-comp.t')
-rwxr-xr-xtest/etap/140-attachment-comp.t319
1 files changed, 141 insertions, 178 deletions
diff --git a/test/etap/140-attachment-comp.t b/test/etap/140-attachment-comp.t
index 475f4fb0..861096a0 100755
--- a/test/etap/140-attachment-comp.t
+++ b/test/etap/140-attachment-comp.t
@@ -33,7 +33,6 @@ test() ->
couch_server_sup:start_link(test_util:config_files()),
put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))),
- application:start(inets),
timer:sleep(1000),
couch_server:delete(test_db_name(), []),
couch_db:create(test_db_name(), []),
@@ -84,22 +83,20 @@ db_url() ->
binary_to_list(test_db_name()).
create_1st_text_att() ->
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ db_url() ++ "/testdoc1/readme.txt",
+ [{"Content-Type", "text/plain"}],
put,
- {db_url() ++ "/testdoc1/readme.txt", [],
- "text/plain", test_text_data()},
- [],
- [{sync, true}]),
+ test_text_data()),
etap:is(Code, 201, "Created text attachment using the standalone api"),
ok.
create_1st_png_att() ->
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ db_url() ++ "/testdoc2/icon.png",
+ [{"Content-Type", "image/png"}],
put,
- {db_url() ++ "/testdoc2/icon.png", [],
- "image/png", test_png_data()},
- [],
- [{sync, true}]),
+ test_png_data()),
etap:is(Code, 201, "Created png attachment using the standalone api"),
ok.
@@ -113,12 +110,11 @@ create_2nd_text_att() ->
]}
}]}}
]},
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ db_url() ++ "/testdoc3",
+ [{"Content-Type", "application/json"}],
put,
- {db_url() ++ "/testdoc3", [],
- "application/json", list_to_binary(couch_util:json_encode(DocJson))},
- [],
- [{sync, true}]),
+ iolist_to_binary(couch_util:json_encode(DocJson))),
etap:is(Code, 201, "Created text attachment using the non-standalone api"),
ok.
@@ -132,22 +128,20 @@ create_2nd_png_att() ->
]}
}]}}
]},
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ db_url() ++ "/testdoc4",
+ [{"Content-Type", "application/json"}],
put,
- {db_url() ++ "/testdoc4", [],
- "application/json", list_to_binary(couch_util:json_encode(DocJson))},
- [],
- [{sync, true}]),
+ iolist_to_binary(couch_util:json_encode(DocJson))),
etap:is(Code, 201, "Created png attachment using the non-standalone api"),
ok.
create_already_compressed_att(DocUri, AttName) ->
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ DocUri ++ "/" ++ AttName,
+ [{"Content-Type", "text/plain"}, {"Content-Encoding", "gzip"}],
put,
- {DocUri ++ "/" ++ AttName, [{"Content-Encoding", "gzip"}],
- "text/plain", zlib:gzip(test_text_data())},
- [],
- [{sync, true}]),
+ zlib:gzip(test_text_data())),
etap:is(
Code,
201,
@@ -183,15 +177,14 @@ tests_for_2nd_png_att() ->
test_2nd_png_att_stub().
test_get_1st_text_att_with_accept_encoding_gzip() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc1/readme.txt", [{"Accept-Encoding", "gzip"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc1/readme.txt",
+ [{"Accept-Encoding", "gzip"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, true, "received body is gziped"),
- Uncompressed = binary_to_list(zlib:gunzip(list_to_binary(Body))),
+ Uncompressed = zlib:gunzip(Body),
etap:is(
Uncompressed,
test_text_data(),
@@ -200,13 +193,12 @@ test_get_1st_text_att_with_accept_encoding_gzip() ->
ok.
test_get_1st_text_att_without_accept_encoding_header() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc1/readme.txt", []},
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc1/readme.txt",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, false, "received body is not gziped"),
etap:is(
Body,
@@ -216,15 +208,14 @@ test_get_1st_text_att_without_accept_encoding_header() ->
ok.
test_get_1st_text_att_with_accept_encoding_deflate() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc1/readme.txt", [{"Accept-Encoding", "deflate"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc1/readme.txt",
+ [{"Accept-Encoding", "deflate"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, false, "received body is not gziped"),
- Deflated = lists:member({"content-encoding", "deflate"}, Headers),
+ Deflated = lists:member({"Content-Encoding", "deflate"}, Headers),
etap:is(Deflated, false, "received body is not deflated"),
etap:is(
Body,
@@ -234,12 +225,10 @@ test_get_1st_text_att_with_accept_encoding_deflate() ->
ok.
test_get_1st_text_att_with_accept_encoding_deflate_only() ->
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
- get,
- {db_url() ++ "/testdoc1/readme.txt",
- [{"Accept-Encoding", "deflate, *;q=0"}]},
- [],
- [{sync, true}]),
+ {ok, Code, _Headers, _Body} = test_util:request(
+ db_url() ++ "/testdoc1/readme.txt",
+ [{"Accept-Encoding", "deflate, *;q=0"}],
+ get),
etap:is(
Code,
406,
@@ -248,13 +237,12 @@ test_get_1st_text_att_with_accept_encoding_deflate_only() ->
ok.
test_get_1st_png_att_without_accept_encoding_header() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc2/icon.png", []},
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc2/icon.png",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Encoding = couch_util:get_value("content-encoding", Headers),
+ Encoding = couch_util:get_value("Content-Encoding", Headers),
etap:is(Encoding, undefined, "received body is not gziped"),
etap:is(
Body,
@@ -264,13 +252,12 @@ test_get_1st_png_att_without_accept_encoding_header() ->
ok.
test_get_1st_png_att_with_accept_encoding_gzip() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc2/icon.png", [{"Accept-Encoding", "gzip"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc2/icon.png",
+ [{"Accept-Encoding", "gzip"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Encoding = couch_util:get_value("content-encoding", Headers),
+ Encoding = couch_util:get_value("Content-Encoding", Headers),
etap:is(Encoding, undefined, "received body is not gziped"),
etap:is(
Body,
@@ -280,13 +267,12 @@ test_get_1st_png_att_with_accept_encoding_gzip() ->
ok.
test_get_1st_png_att_with_accept_encoding_deflate() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc2/icon.png", [{"Accept-Encoding", "deflate"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc2/icon.png",
+ [{"Accept-Encoding", "deflate"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Encoding = couch_util:get_value("content-encoding", Headers),
+ Encoding = couch_util:get_value("Content-Encoding", Headers),
etap:is(Encoding, undefined, "received body is in identity form"),
etap:is(
Body,
@@ -296,12 +282,10 @@ test_get_1st_png_att_with_accept_encoding_deflate() ->
ok.
test_get_doc_with_1st_text_att() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc1?attachments=true",
- [{"Accept", "application/json"}]},
- [],
- [{sync, true}]),
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc1?attachments=true",
+ [{"Accept", "application/json"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
TextAttJson = couch_util:get_nested_json_value(
@@ -331,11 +315,10 @@ test_get_doc_with_1st_text_att() ->
ok.
test_1st_text_att_stub() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc1?att_encoding_info=true", []},
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc1?att_encoding_info=true",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
{TextAttJson} = couch_util:get_nested_json_value(
@@ -345,7 +328,7 @@ test_1st_text_att_stub() ->
TextAttLength = couch_util:get_value(<<"length">>, TextAttJson),
etap:is(
TextAttLength,
- length(test_text_data()),
+ byte_size(test_text_data()),
"1st text attachment stub length matches the uncompressed length"
),
TextAttEncoding = couch_util:get_value(<<"encoding">>, TextAttJson),
@@ -363,12 +346,10 @@ test_1st_text_att_stub() ->
ok.
test_get_doc_with_1st_png_att() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc2?attachments=true",
- [{"Accept", "application/json"}]},
- [],
- [{sync, true}]),
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc2?attachments=true",
+ [{"Accept", "application/json"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
PngAttJson = couch_util:get_nested_json_value(
@@ -392,11 +373,10 @@ test_get_doc_with_1st_png_att() ->
ok.
test_1st_png_att_stub() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc2?att_encoding_info=true", []},
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc2?att_encoding_info=true",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
{PngAttJson} = couch_util:get_nested_json_value(
@@ -406,7 +386,7 @@ test_1st_png_att_stub() ->
PngAttLength = couch_util:get_value(<<"length">>, PngAttJson),
etap:is(
PngAttLength,
- length(test_png_data()),
+ byte_size(test_png_data()),
"1st png attachment stub length matches the uncompressed length"
),
PngEncoding = couch_util:get_value(<<"encoding">>, PngAttJson),
@@ -424,15 +404,14 @@ test_1st_png_att_stub() ->
ok.
test_get_2nd_text_att_with_accept_encoding_gzip() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc3/readme.txt", [{"Accept-Encoding", "gzip"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc3/readme.txt",
+ [{"Accept-Encoding", "gzip"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, true, "received body is gziped"),
- Uncompressed = binary_to_list(zlib:gunzip(list_to_binary(Body))),
+ Uncompressed = zlib:gunzip(Body),
etap:is(
Uncompressed,
test_text_data(),
@@ -441,13 +420,12 @@ test_get_2nd_text_att_with_accept_encoding_gzip() ->
ok.
test_get_2nd_text_att_without_accept_encoding_header() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc3/readme.txt", []},
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc3/readme.txt",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, false, "received body is not gziped"),
etap:is(
Body,
@@ -457,13 +435,12 @@ test_get_2nd_text_att_without_accept_encoding_header() ->
ok.
test_get_2nd_png_att_without_accept_encoding_header() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc4/icon.png", []},
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc4/icon.png",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, false, "received body is not gziped"),
etap:is(
Body,
@@ -473,13 +450,12 @@ test_get_2nd_png_att_without_accept_encoding_header() ->
ok.
test_get_2nd_png_att_with_accept_encoding_gzip() ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc4/icon.png", [{"Accept-Encoding", "gzip"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc4/icon.png",
+ [{"Accept-Encoding", "gzip"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, false, "received body is not gziped"),
etap:is(
Body,
@@ -489,12 +465,10 @@ test_get_2nd_png_att_with_accept_encoding_gzip() ->
ok.
test_get_doc_with_2nd_text_att() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc3?attachments=true",
- [{"Accept", "application/json"}]},
- [],
- [{sync, true}]),
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc3?attachments=true",
+ [{"Accept", "application/json"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
TextAttJson = couch_util:get_nested_json_value(
@@ -520,11 +494,10 @@ test_get_doc_with_2nd_text_att() ->
ok.
test_2nd_text_att_stub() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc3?att_encoding_info=true", []},
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc3?att_encoding_info=true",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
{TextAttJson} = couch_util:get_nested_json_value(
@@ -534,7 +507,7 @@ test_2nd_text_att_stub() ->
TextAttLength = couch_util:get_value(<<"length">>, TextAttJson),
etap:is(
TextAttLength,
- length(test_text_data()),
+ byte_size(test_text_data()),
"2nd text attachment stub length matches the uncompressed length"
),
TextAttEncoding = couch_util:get_value(<<"encoding">>, TextAttJson),
@@ -552,12 +525,10 @@ test_2nd_text_att_stub() ->
ok.
test_get_doc_with_2nd_png_att() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc4?attachments=true",
- [{"Accept", "application/json"}]},
- [],
- [{sync, true}]),
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc4?attachments=true",
+ [{"Accept", "application/json"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
PngAttJson = couch_util:get_nested_json_value(
@@ -581,11 +552,10 @@ test_get_doc_with_2nd_png_att() ->
ok.
test_2nd_png_att_stub() ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc4?att_encoding_info=true", []},
+ {ok, Code, _Headers, Body} = test_util:request(
+ db_url() ++ "/testdoc4?att_encoding_info=true",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
{PngAttJson} = couch_util:get_nested_json_value(
@@ -595,7 +565,7 @@ test_2nd_png_att_stub() ->
PngAttLength = couch_util:get_value(<<"length">>, PngAttJson),
etap:is(
PngAttLength,
- length(test_png_data()),
+ byte_size(test_png_data()),
"2nd png attachment stub length matches the uncompressed length"
),
PngEncoding = couch_util:get_value(<<"encoding">>, PngAttJson),
@@ -618,43 +588,40 @@ test_already_compressed_att(DocUri, AttName) ->
test_get_already_compressed_att_stub(DocUri, AttName).
test_get_already_compressed_att_with_accept_gzip(DocUri, AttName) ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {DocUri ++ "/" ++ AttName, [{"Accept-Encoding", "gzip"}]},
- [],
- [{sync, true}]),
+ {ok, Code, Headers, Body} = test_util:request(
+ DocUri ++ "/" ++ AttName,
+ [{"Accept-Encoding", "gzip"}],
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, true, "received body is gziped"),
etap:is(
- iolist_to_binary(Body),
- iolist_to_binary(zlib:gzip(test_text_data())),
+ Body,
+ zlib:gzip(test_text_data()),
"received data for the already compressed attachment is ok"
),
ok.
test_get_already_compressed_att_without_accept(DocUri, AttName) ->
- {ok, {{_, Code, _}, Headers, Body}} = http:request(
- get,
- {DocUri ++ "/" ++ AttName, []},
+ {ok, Code, Headers, Body} = test_util:request(
+ DocUri ++ "/" ++ AttName,
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers),
etap:is(Gziped, false, "received body is not gziped"),
etap:is(
- iolist_to_binary(Body),
- iolist_to_binary(test_text_data()),
+ Body,
+ test_text_data(),
"received data for the already compressed attachment is ok"
),
ok.
test_get_already_compressed_att_stub(DocUri, AttName) ->
- {ok, {{_, Code, _}, _Headers, Body}} = http:request(
- get,
- {DocUri ++ "?att_encoding_info=true", []},
+ {ok, Code, _Headers, Body} = test_util:request(
+ DocUri ++ "?att_encoding_info=true",
[],
- [{sync, true}]),
+ get),
etap:is(Code, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body),
{AttJson} = couch_util:get_nested_json_value(
@@ -685,12 +652,11 @@ test_get_already_compressed_att_stub(DocUri, AttName) ->
test_create_already_compressed_att_with_invalid_content_encoding(
DocUri, AttName, AttData, Encoding) ->
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ DocUri ++ "/" ++ AttName,
+ [{"Content-Encoding", Encoding}, {"Content-Type", "text/plain"}],
put,
- {DocUri ++ "/" ++ AttName, [{"Content-Encoding", Encoding}],
- "text/plain", AttData},
- [],
- [{sync, true}]),
+ AttData),
etap:is(
Code,
415,
@@ -700,29 +666,26 @@ test_create_already_compressed_att_with_invalid_content_encoding(
ok.
test_compressible_type_with_parameters() ->
- {ok, {{_, Code, _}, _Headers, _Body}} = http:request(
+ {ok, Code, _Headers, _Body} = test_util:request(
+ db_url() ++ "/testdoc5/readme.txt",
+ [{"Content-Type", "text/plain; charset=UTF-8"}],
put,
- {db_url() ++ "/testdoc5/readme.txt", [],
- "text/plain; charset=UTF-8", test_text_data()},
- [],
- [{sync, true}]),
+ test_text_data()),
etap:is(Code, 201, "Created text attachment with MIME type "
"'text/plain; charset=UTF-8' using the standalone api"),
- {ok, {{_, Code2, _}, Headers2, Body}} = http:request(
- get,
- {db_url() ++ "/testdoc5/readme.txt", [{"Accept-Encoding", "gzip"}]},
- [],
- [{sync, true}]),
+ {ok, Code2, Headers2, Body} = test_util:request(
+ db_url() ++ "/testdoc5/readme.txt",
+ [{"Accept-Encoding", "gzip"}],
+ get),
etap:is(Code2, 200, "HTTP response code is 200"),
- Gziped = lists:member({"content-encoding", "gzip"}, Headers2),
+ Gziped = lists:member({"Content-Encoding", "gzip"}, Headers2),
etap:is(Gziped, true, "received body is gziped"),
- Uncompressed = binary_to_list(zlib:gunzip(list_to_binary(Body))),
+ Uncompressed = zlib:gunzip(Body),
etap:is(Uncompressed, test_text_data(), "received data is gzipped"),
- {ok, {{_, Code3, _}, _Headers3, Body3}} = http:request(
- get,
- {db_url() ++ "/testdoc5?att_encoding_info=true", []},
+ {ok, Code3, _Headers3, Body3} = test_util:request(
+ db_url() ++ "/testdoc5?att_encoding_info=true",
[],
- [{sync, true}]),
+ get),
etap:is(Code3, 200, "HTTP response code is 200"),
Json = couch_util:json_decode(Body3),
{TextAttJson} = couch_util:get_nested_json_value(
@@ -732,7 +695,7 @@ test_compressible_type_with_parameters() ->
TextAttLength = couch_util:get_value(<<"length">>, TextAttJson),
etap:is(
TextAttLength,
- length(test_text_data()),
+ byte_size(test_text_data()),
"text attachment stub length matches the uncompressed length"
),
TextAttEncoding = couch_util:get_value(<<"encoding">>, TextAttJson),
@@ -753,10 +716,10 @@ test_png_data() ->
{ok, Data} = file:read_file(
test_util:source_file("share/www/image/logo.png")
),
- binary_to_list(Data).
+ Data.
test_text_data() ->
{ok, Data} = file:read_file(
test_util:source_file("README")
),
- binary_to_list(Data).
+ Data.