cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Help debugging Curl PHP script when downloading PDF

From: Rick Rodriguez <me_at_rickrodriguezjr.com>
Date: Sun, 23 Nov 2008 09:11:34 -0500

Hi everyone,

 

I am new here and I was wondering if I could get your thoughts and ideas on
an issue I am having when trying to download a PDF document.

 

 

Problem:

I am currently trying to write a PDF class that will allow me to traverse a
site so that I can download a pdf on a daily basis. Currently, the class
that I created will authenticate itself with the server,

Follow the redirects all the way to the point where the link to the pdf is
found. The class has to access the link, because the link is dynamic and it
will change on a daily basis. Everything works fine with cookie sessions
and redirects all the way to the link. Upon clicking on the link, Curl
returns a 1 but no data. On the browser, normally when you would click on
the link it opens a Save As dialog window. However, my problem is when
running the script I get no data back but curl returns 1.

 

The significant part is highlighted. This is the point where I should be
getting my data back but I am not. Curl in debug mode shows that the
content-type is text/html, shouldn't that be application/???

 

Script Debug Output:

(notes): Due to some reasons, I have had to replace authentication
parameters and URL.

 

* About to connect() to inet.somesite.com port 443

* Trying 151.25.45.522... * connected

* Connected to ilnet.somesite.com (151.25.45.522) port 443

* successfully set certificate verify locations:

* CAfile: /etc/pki/tls/certs/ca-bundle.crt

  CApath: none

* SSL connection using RC4-MD5

* Server certificate:

* subject: /O=Site Test/OU=DMZ Purplenet/CN=ilnet.somesite.com

* start date: 2008-07-03 17:19:14 GMT

* expire date: 2009-07-03 17:19:14 GMT

* subjectAltName: ilnet.somesite.com matched

* issuer: /C=US/O=Site Test/OU=Site Test Certification
Authority/CN=Site Test Certificate Authority 01

* SSL certificate verify ok.

> POST /ilonline/Login.wf HTTP/1.1

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4

Accept-Encoding: gzip,deflate

Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5

Cache-Control: max-age=0

Connection: keep-alive

Keep-Alive: 300

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Referer: https://ilnet.somesite.com/ilonline/funding/SessionExpired.jsp?e=2

Host: ilnet.somesite.com

Content-Type: application/x-www-form-urlencoded

Content-Length: 78

 

MEMBER_ID=xxxxx&USER_ID=xxxxx&PASSWORD=xxxxx&goButton=Go&CHANNEL=FUNDING<
HTTP/1.1 302 Found

< Server: Sun-ONE-Web-Server/6.1

< Date: Sun, 23 Nov 2008 13:48:58 GMT

< Content-type: text/html; charset=ISO-8859-1

< Pragma: no-cache

< Cache-control: no-cache

< Expires: Thu, 01 Jan 1970 00:00:00 GMT

< Location:
https://ilnet.somesite.com/ilonline/crs/successfulLoginRedirect.jsp

< Content-language: en-US

* Added cookie JSESSIONID="0000Sqo383hdw2fwMdQa-hPQVYL:13ekm94lv" for domain
ilnet.somesite.com, path /, expire 0

< Set-cookie: JSESSIONID=0000Sqo383hdw2fwMdQa-hPQVYL:13ekm94lv; Path=/

* Replaced cookie JSESSIONID="0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv" for
domain ilnet.somesite.com, path /, expire 0

< Set-cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv; Path=/

< Transfer-encoding: chunked

* Ignoring the response-body

* Connection #0 to host ilnet.somesite.com left intact

* Issue another request to this URL:
'https://ilnet.somesite.com/ilonline/crs/successfulLoginRedirect.jsp'

* Disables POST, goes with GET

* Re-using existing connection! (#0) with host ilnet.somesite.com

* Connected to ilnet.somesite.com (151.25.45.522) port 443

> GET /ilonline/crs/successfulLoginRedirect.jsp HTTP/1.1

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4

Accept-Encoding: gzip,deflate

Cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv

Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5

Cache-Control: max-age=0

Connection: keep-alive

Keep-Alive: 300

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Referer: https://ilnet.somesite.com/ilonline/funding/SessionExpired.jsp?e=2

Host: ilnet.somesite.com

Content-Type: application/x-www-form-urlencoded

 

< HTTP/1.1 200 OK

< Server: Sun-ONE-Web-Server/6.1

< Date: Sun, 23 Nov 2008 13:48:58 GMT

< Content-length: 503

< Content-type: text/html;charset=ISO-8859-1

< Content-language: en-US

* Connection #0 to host ilnet.somesite.com left intact

Going to the rate sheets!

HEADER: Array

(

    [0] => Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5

    [1] => Cache-Control: max-age=0

    [2] => Connection: keep-alive

    [3] => Keep-Alive: 300

    [4] => Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    [5] => Accept-Language: en-us,en;q=0.5

    [6] => Referer: https://ilnet.somesite.com/ilonline/mainStartAction.do

    [7] => Pragma:

    [8] => Host: ilnet.somesite.com

    [9] => Content-Type: application/x-www-form-urlencoded

)

* Re-using existing connection! (#0) with host ilnet.somesite.com

* Connected to ilnet.somesite.com (151.25.45.522) port 443

> GET /ilonline/RateSheet.wf HTTP/1.1

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4

Accept-Encoding: gzip,deflate

Cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv

Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5

Cache-Control: max-age=0

Connection: keep-alive

Keep-Alive: 300

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Referer: https://ilnet.somesite.com/ilonline/mainStartAction.do

Host: ilnet.somesite.com

Content-Type: application/x-www-form-urlencoded

 

< HTTP/1.1 302 Found

< Server: Sun-ONE-Web-Server/6.1

< Date: Sun, 23 Nov 2008 13:48:59 GMT

< Content-type: text/html; charset=ISO-8859-1

< Location:
https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp

< Content-language: en-US

< Transfer-encoding: chunked

* Ignoring the response-body

* Connection #0 to host ilnet.somesite.com left intact

* Issue another request to this URL:
'https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp'

* Re-using existing connection! (#0) with host ilnet.somesite.com

* Connected to ilnet.somesite.com (151.25.45.522) port 443

> GET /ilonline/crs/ratesheets/ratesheets.jsp HTTP/1.1

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4

Accept-Encoding: gzip,deflate

Cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv

Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5

Cache-Control: max-age=0

Connection: keep-alive

Keep-Alive: 300

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Referer: https://ilnet.somesite.com/ilonline/mainStartAction.do

Host: ilnet.somesite.com

Content-Type: application/x-www-form-urlencoded

 

< HTTP/1.1 200 OK

< Server: Sun-ONE-Web-Server/6.1

< Date: Sun, 23 Nov 2008 13:48:59 GMT

< Content-length: 12175

< Content-type: text/html;charset=ISO-8859-1

< Content-language: en-US

* Connection #0 to host ilnet.somesite.com left intact

++++

--Array

(

    [url] =>
https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp

    [content_type] => text/html;charset=ISO-8859-1

    [http_code] => 200

    [header_size] => 448

    [request_size] => 1333

    [filetime] => -1

    [ssl_verify_result] => 0

    [redirect_count] => 1

    [total_time] => 0.540092

    [namelookup_time] => 7.3E-05

    [connect_time] => 8.3E-05

    [pretransfer_time] => 0.000294

    [size_upload] => 0

    [size_download] => 12175

    [speed_download] => 22542

    [speed_upload] => 0

    [download_content_length] => 12175

    [upload_content_length] => 0

    [starttransfer_time] => 0.158054

    [redirect_time] => 0.370371

)

--
HEADER: Array
(
    [0] => Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
    [1] => Cache-Control: max-age=0
    [2] => Connection: keep-alive
    [3] => Keep-Alive: 300
    [4] => Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [5] => Accept-Language: en-us,en;q=0.5
    [6] => Referer: https://ilnet.somesite.com/ilonline/mainStartAction.do
    [7] => Pragma: 
    [8] => Host: ilnet.somesite.com
    [9] => Content-Type: application/x-www-form-urlencoded
)
* Re-using existing connection! (#0) with host ilnet.somesite.com
* Connected to ilnet.somesite.com (151.25.45.522) port 443
> GET /ilonline/RateSheet.wf?stateCode=al&rateSheetType=trad_brok HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4
Accept-Encoding: gzip,deflate
Cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
Cache-Control: max-age=0
Connection: keep-alive
Keep-Alive: 300
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Referer: https://ilnet.somesite.com/ilonline/mainStartAction.do
Host: ilnet.somesite.com
Content-Type: application/x-www-form-urlencoded
 
< HTTP/1.1 302 Found
< Server: Sun-ONE-Web-Server/6.1
< Date: Sun, 23 Nov 2008 13:48:59 GMT
< Content-type: text/html; charset=ISO-8859-1
< Location:
https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp
< Content-language: en-US
< Transfer-encoding: chunked
* Ignoring the response-body
* Connection #0 to host ilnet.somesite.com left intact
* Issue another request to this URL:
'https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp'
* Re-using existing connection! (#0) with host ilnet.somesite.com
* Connected to ilnet.somesite.com (151.25.45.522) port 443
> GET /ilonline/crs/ratesheets/ratesheets.jsp HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4
Accept-Encoding: gzip,deflate
Cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
Cache-Control: max-age=0
Connection: keep-alive
Keep-Alive: 300
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Referer: https://ilnet.somesite.com/ilonline/mainStartAction.do
Host: ilnet.somesite.com
Content-Type: application/x-www-form-urlencoded
 
< HTTP/1.1 200 OK
< Server: Sun-ONE-Web-Server/6.1
< Date: Sun, 23 Nov 2008 13:48:59 GMT
< Content-type: text/html;charset=ISO-8859-1
< Content-language: en-US
< Transfer-encoding: chunked
* Connection #0 to host ilnet.somesite.com left intact
++++
--Array
(
    [url] =>
https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp
    [content_type] => text/html;charset=ISO-8859-1
    [http_code] => 200
    [header_size] => 453
    [request_size] => 1370
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 1
    [total_time] => 0.923073
    [namelookup_time] => 7.7E-05
    [connect_time] => 8.6E-05
    [pretransfer_time] => 0.000315
    [size_upload] => 0
    [size_download] => 109554
    [speed_download] => 118684
    [speed_upload] => 0
    [download_content_length] => 12175
    [upload_content_length] => 0
    [starttransfer_time] => 0.338204
    [redirect_time] => 0.179193
)
--
Get PDF
(https://ilnet.somesite.com/ilonline/SecureDownload.wf?file=uploadedrateshee
ts/ilonline/SecureDownload.wf?file=uploadedratesheets/trad_brok_al/2008.11.2
1.pm.2.35.5652.trad_brok_al.acrobat.pdf).
HEADER: Array
(
    [0] => GET
/ilonline/SecureDownload.wf?file=/ilonline/SecureDownload.wf?file=uploadedra
tesheets/trad_brok_al/2008.11.21.pm.2.35.5652.trad_brok_al.acrobat.pdf
HTTP/1.1
    [1] => 
    [2] => Host: ilnet.somesite.com
    [3] => User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
    [4] => Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [5] => Accept-Language: en-us,en;q=0.5
    [6] => Accept-Encoding: gzip,deflate
    [7] => Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    [8] => Keep-Alive: 300
    [9] => Connection: keep-alive
    [10] => Referer:
https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp
)
* Re-using existing connection! (#0) with host ilnet.somesite.com
* Connected to ilnet.somesite.com (151.25.45.522) port 443
> GET
/ilonline/SecureDownload.wf?file=uploadedratesheets/ilonline/SecureDownload.
wf?file=uploadedratesheets/trad_brok_al/2008.11.21.pm.2.35.5652.trad_brok_al
.acrobat.pdf HTTP/1.1
Accept-Encoding: gzip,deflate
Cookie: JSESSIONID=0000mfJ8EdY_IXcNWpJDVEOTiTJ:13ekm94lv
Host: ilnet.somesite.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: https://ilnet.somesite.com/ilonline/crs/ratesheets/ratesheets.jsp
 
< HTTP/1.1 200 OK
< Server: Sun-ONE-Web-Server/6.1
< Date: Sun, 23 Nov 2008 13:49:00 GMT
< Content-type: text/html; charset=ISO-8859-1
< Content-language: en-US
< Transfer-encoding: chunked
* Connection #0 to host ilnet.somesite.com left intact
++++
--Array
(
    [url] =>
https://ilnet.somesite.com/ilonline/SecureDownload.wf?file=uploadedratesheet
s/ilonline/SecureDownload.wf?file=uploadedratesheets/trad_brok_al/2008.11.21
.pm.2.35.5652.trad_brok_al.acrobat.pdf
    [content_type] => text/html; charset=ISO-8859-1
    [http_code] => 200
    [header_size] => 186
    [request_size] => 706
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.131808
    [namelookup_time] => 0.000108
    [connect_time] => 0.000119
    [pretransfer_time] => 0.000372
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 12175
    [upload_content_length] => 0
    [starttransfer_time] => 0.131662
    [redirect_time] => 0
)
 
--
 
1

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-11-23