@@ -284,7 +284,8 @@ timeout/
284284--- timeout: 5
285285
286286
287- === TEST 4.1: watchdir(key=="")
287+
288+ === TEST 6: watchdir(key=="")
288289--- http_config eval: $::HttpConfig
289290--- config
290291 location /t {
@@ -348,7 +349,7 @@ timeout/
348349
349350
350351
351- === TEST 6 : setx(key, val) failed
352+ === TEST 7 : setx(key, val) failed
352353--- http_config eval: $::HttpConfig
353354--- config
354355 location /t {
@@ -369,7 +370,7 @@ GET /t
369370
370371
371372
372- === TEST 7 : setx(key, val) success
373+ === TEST 8 : setx(key, val) success
373374--- http_config eval: $::HttpConfig
374375--- config
375376 location /t {
@@ -395,7 +396,7 @@ checked val as expect: abd
395396
396397
397398
398- === TEST 8 : setnx(key, val)
399+ === TEST 9 : setnx(key, val)
399400--- http_config eval: $::HttpConfig
400401--- config
401402 location /t {
@@ -422,3 +423,92 @@ GET /t
422423[error]
423424--- response_body
424425checked val as expect: aaa
426+
427+
428+
429+ === TEST 10: set extra_headers for request_uri
430+ --- http_config eval: $::HttpConfig
431+ --- config
432+ location /t {
433+ content_by_lua_block {
434+ local etcd, err = require "resty.etcd" .new({
435+ protocol = "v3",
436+ extra_headers = {
437+ foo = "bar",
438+ }
439+ })
440+ check_res(etcd, err)
441+
442+ local res, err = etcd:set("/test", "abc", {prev_kv = true})
443+ check_res(res, err)
444+
445+ local data, err = etcd:get("/test")
446+ check_res(data, err, "abc")
447+ }
448+ }
449+ --- request
450+ GET /t
451+ --- no_error_log
452+ [error]
453+ --- response_body
454+ checked val as expect: abc
455+ --- error_log
456+ request uri headers: {"foo":"bar"}
457+
458+
459+
460+ === TEST 11: Authorization header will not be overridden
461+ --- http_config eval: $::HttpConfig
462+ --- config
463+ location /t {
464+ content_by_lua_block {
465+ local etcd, err = require "resty.etcd" .new({
466+ protocol = "v3",
467+ extra_headers = {
468+ Authorization = "bar",
469+ }
470+ })
471+ check_res(etcd, err)
472+
473+ local res, err = etcd:set("/test", "abc", {prev_kv = true})
474+ check_res(res, err)
475+
476+ local data, err = etcd:get("/test")
477+ check_res(data, err, "abc")
478+ }
479+ }
480+ --- request
481+ GET /t
482+ --- no_error_log
483+ [error]
484+ --- response_body
485+ checked val as expect: abc
486+ --- error_log
487+ request uri headers: {}
488+
489+
490+
491+ === TEST 12: set extra_headers for request_chunk
492+ --- http_config eval: $::HttpConfig
493+ --- config
494+ location /t {
495+ content_by_lua_block {
496+ local etcd, err = require "resty.etcd" .new({
497+ protocol = "v3",
498+ extra_headers = {
499+ foo = "bar",
500+ }
501+ })
502+ local res, err = etcd:set("/test", "abc")
503+ local body_chunk_fun, _ = etcd:watch("/test", {timeout = 0.5})
504+ ngx.say("passed")
505+ }
506+ }
507+ --- request
508+ GET /t
509+ --- response_body
510+ passed
511+ --- error_log
512+ request chunk headers: {"foo":"bar"}
513+ --- no_error_log
514+ [error]
0 commit comments