add_subdirectory(header)

if(NOT BUILD_HTTP)
  return()
endif()

add_subdirectory(put)

add_bats_tests(cors.bats)
add_bats_tests(digest.bats)
add_bats_tests(headers.bats)
add_bats_tests(html.bats)
add_bats_tests(limits.bats)
add_bats_tests(login.bats)
add_bats_tests(pipeline.bats)
add_bats_tests(port.bats)
add_bats_tests(redirect.bats)
add_bats_tests(rfc9112.bats)
add_bats_tests(range.bats)
add_bats_tests(smuggling.bats)
add_bats_tests(trailers.bats)

# The tests of the client use the XrdClHttp plugin, which only exists when
# libcurl was found
if(TARGET XrdClHttpObj)
  add_bats_tests(dav.bats)
  add_bats_tests(errors.bats)

  find_package(CURL REQUIRED)
  add_executable(xrdhttp-stress HttpStress.cc)
  target_link_libraries(xrdhttp-stress GTest::gtest GTest::gtest_main CURL::libcurl)
  add_bats_tests(stress.bats)
endif()

if(BUILD_HTTP AND TARGET XrdClHttpObj AND TARGET xrootd AND TARGET xrdfs)
  add_subdirectory(worker)
endif()
