1--  Licensed to the Apache Software Foundation (ASF) under one
2--  or more contributor license agreements.  See the NOTICE file
3--  distributed with this work for additional information
4--  regarding copyright ownership.  The ASF licenses this file
5--  to you under the Apache License, Version 2.0 (the
6--  "License"); you may not use this file except in compliance
7--  with the License.  You may obtain a copy of the License at
8--
9--  http://www.apache.org/licenses/LICENSE-2.0
10--
11--  Unless required by applicable law or agreed to in writing, software
12--  distributed under the License is distributed on an "AS IS" BASIS,
13--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14--  See the License for the specific language governing permissions and
15--  limitations under the License.
16
17
18function schedule()
19    ts.debug('test schedule starts')
20
21    -- test.com needs to be handled by ATS in remap.config
22    local url = 'http://test.com/test.php'
23    local res = ts.fetch(url)
24    ts.debug('test fetch')
25    if res.status == 200 then
26        local b = res.body
27        local len = string.len(b)
28        ts.debug(len)
29    end
30    ts.debug('test schedule ends')
31end
32
33function cache_lookup()
34  ts.debug('cache-lookup')
35  ts.schedule(TS_LUA_THREAD_POOL_NET, 0, schedule)
36  return 0
37end
38
39function do_global_read_request()
40    local inner = ts.http.is_internal_request()
41    if inner ~= 0 then
42        ts.debug('internal')
43        return 0
44    end
45
46    ts.hook(TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE, cache_lookup)
47    return 0
48end
49