@@ -221,6 +221,8 @@ async function slow(req, res, next) {
221221
222222 let delay = req . query . delay ;
223223
224+ let nocl = req . query . nocl ;
225+
224226 if ( delay !== undefined ) {
225227 delay = parseFloat ( delay ) ;
226228 await sleep ( delay * 1000 ) ;
@@ -237,6 +239,10 @@ async function slow(req, res, next) {
237239
238240 let location = `${ locals . base_uri } /poll?id=${ poll_id } ` ;
239241
242+ if ( nocl === '1' ) {
243+ location = `${ location } &nocl=1` ;
244+ }
245+
240246 let headers = new MultiValueHeaders ( [
241247 "Content-Type" , "application/json" ,
242248 "Content-Location" , location
@@ -266,6 +272,7 @@ async function delete_poll(req, res, next) {
266272async function poll ( req , res , next ) {
267273
268274 let poll_id = req . query . id ;
275+ let nocl = req . query . nocl ;
269276 let headers = req . rawHeaders . asMultiValue ( ) ;
270277 let cookies = headers . cookies ( 'cookie' ) ;
271278 let locals = req . app . locals ;
@@ -283,17 +290,25 @@ async function poll(req, res, next) {
283290
284291 let tracking = locals . tracked [ poll_id ] ;
285292
286- if ( new Date ( ) < tracking . finish_at ) {
287- respond ( req , res , next , 202 , new MultiValueHeaders ( [ 'Content-Location' , `${ locals . base_uri } /poll?id=${ poll_id } ` ] ) ) ;
288- return ;
289- }
290293
291294 let resp_headers = new MultiValueHeaders ( ) ;
292295
293296 if ( poll_count !== undefined ) {
294297 resp_headers . withNewCookies ( { "poll-count" : `poll-count=${ poll_count } ` } , 'set-cookie' ) ;
295298 }
296299
300+
301+ if ( new Date ( ) < tracking . finish_at ) {
302+
303+ if ( nocl !== '1' ) {
304+ resp_headers . set ( 'Content-Location' , `${ locals . base_uri } /poll?id=${ poll_id } ` )
305+ }
306+ respond ( req , res , next , 202 , resp_headers ) ;
307+ return ;
308+ }
309+
310+
311+
297312 delete locals . tracked [ poll_id ] ;
298313
299314 respond ( req , res , next , tracking . final_status , resp_headers ) ;
0 commit comments