#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

#
# Create a cached response with a max-age of 300 seconds.
#
# This replay file assumes that negative caching is configured to result in the
# caching of 404 responses (as is the case with default negative caching
# configuration.)
#

meta:
  version: "1.0"

  blocks:
  - request_404_item: &request_404_item
      client-request:
        method: "GET"
        version: "1.1"
        scheme: "http"
        url: /path/404_300_second_timeout
        headers:
          fields:
          - [ Host, example.com ]

        # Add a delay so ATS has time to finish any caching IO for the previous
        # transaction.
        delay: 100ms

sessions:
- transactions:

  - all: { headers: { fields: [[ uuid, 21 ]]}}
    <<: *request_404_item

    # Populate the cache with a 404 response.
    server-response:
      status: 404
      reason: "Not Found"
      headers:
        fields:
        - [ Content-Length, 32 ]
        - [ Cache-Control, max-age=300 ]

    proxy-response:
      status: 404

  - all: { headers: { fields: [[ uuid, 22 ]]}}
    <<: *request_404_item

    # 404 responses should be cached when negative caching is enabled, so this
    # should not get to the server.  But if it does, return a 200 so the test
    # knows that something went wrong.
    server-response:
      status: 200
      reason: OK
      headers:
        fields:
        - [ Content-Length, 0 ]

    # Expect the cached 404 response.
    proxy-response:
      status: 404
