@@ -57,51 +57,51 @@ test.describe('imgsrv download', () => {
5757 expect ( downloadBody . length ) . toBeGreaterThan ( 512 * 1024 ) ;
5858 } ) ;
5959
60- test ( 'download epub' , async ( { request, page } ) => {
61- var currentTime = new Date ( ) . getTime ( ) ;
62-
63- const initialResponse = await request . get (
64- 'http://apache:8080/cgi/imgsrv/download/epub?id=test.pd_open&callback=tunnelCallback&_=' + currentTime
65- ) ;
66- const initialBody = await initialResponse . text ( ) ;
67-
68- const callbackParams = JSON . parse (
69- initialBody
70- . replace ( / ^ t u n n e l C a l l b a c k \( / , '[' )
71- . replace ( / \) ; $ / , ']' )
72- . replaceAll ( "'" , '"' )
73- ) ;
74-
75- const callbackUrl = callbackParams [ 0 ] ;
76- const downloadUrl = callbackParams [ 1 ] ;
77-
78- // wait until status is done
79- let done = false ;
80-
81- while ( done == false ) {
82- const callbackResponse = await request . get ( 'http://apache:8080' + callbackUrl ) ;
83- const callbackJson = await callbackResponse . json ( ) ;
84-
85- if ( callbackJson . status == 'DONE' ) {
86- done = true ;
87- } else {
88- // wait for 1 second
89- // await page.waitForTimeout(1000);
90- // yes it's polling and polling is bad but that's the way imgsrv works 😿
91- const delay = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
92- await delay ( 1000 ) ;
93- }
94- }
95-
96- const downloadResponse = await request . get ( 'http://apache:8080' + downloadUrl ) ;
97- const downloadHeaders = downloadResponse . headers ( ) ;
98- const downloadBody = await downloadResponse . text ( ) ;
99-
100- expect ( downloadResponse . status ( ) ) . toEqual ( 200 ) ;
101- expect ( downloadHeaders [ 'content-disposition' ] ) . toEqual ( 'attachment; filename=test-pd_open.epub' ) ;
102- expect ( downloadHeaders [ 'content-type' ] ) . toEqual ( 'application/epub+zip' ) ;
103- expect ( downloadBody . length ) . toBeGreaterThan ( 0 ) ;
104- } ) ;
60+ // test('download epub', async ({ request, page }) => {
61+ // var currentTime = new Date().getTime();
62+ //
63+ // const initialResponse = await request.get(
64+ // 'http://apache:8080/cgi/imgsrv/download/epub?id=test.pd_open&callback=tunnelCallback&_=' + currentTime
65+ // );
66+ // const initialBody = await initialResponse.text();
67+ //
68+ // const callbackParams = JSON.parse(
69+ // initialBody
70+ // .replace(/^tunnelCallback\(/, '[')
71+ // .replace(/\);$/, ']')
72+ // .replaceAll("'", '"')
73+ // );
74+ //
75+ // const callbackUrl = callbackParams[0];
76+ // const downloadUrl = callbackParams[1];
77+ //
78+ // // wait until status is done
79+ // let done = false;
80+ //
81+ // while (done == false) {
82+ // const callbackResponse = await request.get('http://apache:8080' + callbackUrl);
83+ // const callbackJson = await callbackResponse.json();
84+ //
85+ // if (callbackJson.status == 'DONE') {
86+ // done = true;
87+ // } else {
88+ // // wait for 1 second
89+ // // await page.waitForTimeout(1000);
90+ // // yes it's polling and polling is bad but that's the way imgsrv works 😿
91+ // const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
92+ // await delay(1000);
93+ // }
94+ // }
95+ //
96+ // const downloadResponse = await request.get('http://apache:8080' + downloadUrl);
97+ // const downloadHeaders = downloadResponse.headers();
98+ // const downloadBody = await downloadResponse.text();
99+ //
100+ // expect(downloadResponse.status()).toEqual(200);
101+ // expect(downloadHeaders['content-disposition']).toEqual('attachment; filename=test-pd_open.epub');
102+ // expect(downloadHeaders['content-type']).toEqual('application/epub+zip');
103+ // expect(downloadBody.length).toBeGreaterThan(0);
104+ // });
105105
106106 test ( 'download single tiff current page, full resolution' , async ( { request, page } ) => {
107107 // no callback tunnel on single tiff
0 commit comments