473,769 Members | 5,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cURL return last effective url, but don't download content?

Suppose I have something like this

$resource = curl_init();
curl_setopt($re source, CURLOPT_FOLLOWL OCATION, TRUE);
curl_setopt($re source, CURLOPT_RETURNT RANSFER, TRUE);
curl_setopt($re source, CURLOPT_URL, '......');
curl_exec($reso urce);
$lastUrl = curl_getinfo($r esource, CURLINFO_EFFECT IVE_URL);
curl_close($res ource);

I'm only interested in the $lastUrl address. Is it possible without
wasting bandwidth on downloading the actual trasfer which is at that
address?

Setting RETURNTRANSFER to FALSE outputs transfer directly
Aug 1 '08
10 4395
On Aug 1, 9:47 pm, Mikhail Kovalev <mikhail_kova.. .@mail.ruwrote:
Suppose I have something like this

$resource = curl_init();
curl_setopt($re source, CURLOPT_FOLLOWL OCATION, TRUE);
curl_setopt($re source, CURLOPT_RETURNT RANSFER, TRUE);
curl_setopt($re source, CURLOPT_URL, '......');
curl_exec($reso urce);
$lastUrl = curl_getinfo($r esource, CURLINFO_EFFECT IVE_URL);
curl_close($res ource);

I'm only interested in the $lastUrl address. Is it possible without
wasting bandwidth on downloading the actual trasfer which is at that
address?

Setting RETURNTRANSFER to FALSE outputs transfer directly
I don't know if this is any help to you, because I don't really
understand what you're trying to do and I've never really had much
exposure to curl before, but HTTP supports a HEAD mode. When a HTTP
request occurs it is usually done with a GET, meaning "Send me this
file". If you send HEAD instead of GET the server interoperates it as
"Send me the headers you would have sent if you had sent me the whole
file as normal, but don't send the actual file". Maybe if you use
HEAD to access the data you want you can avoid the overhead of
fetching the whole file. There are restrictions on HEAD, however, you
can't use POST to send the receiver anything. I don't think you can
use GET variables (The ?foo=bar&baz=qu ux style query strings) either,
but if you can live with these restrictions then it should be helpful
to you.
Aug 12 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2489
by: Phil Powell | last post by:
What is the most standardized method of utilizing the CURL functions in PHP (version 4.3.2) to be able to retrieve the contents of a remote URL that happens to be dependent upon $_SESSION for its content display? I've tried the following class methods for display and I have most everything working until I get to a URL that requires $_SESSION: class Timer extends View {
6
3355
by: benji | last post by:
I have set up a system to download datafeeds in pain text or zipped. The download part of this system uses the curl extension to download the files. All was well when I tested it with various datafeeds in zipped and unzipped formats until I came to download zipped files from the affiliate program we are starting with. I have verified that the datafeeds download properly in Internet Explorer but interestingly they also fail in Firefox.
0
1467
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what you deemed an innocent post? The following tips will not only help you, they will help us help you. Please note: The latest changes to this document are marked with a | at the left-most side of the line that has been changed.
4
12167
by: BinnyVA | last post by:
Hi, I am using PHP 5.1.2 with curl enabled. But whenever I try to use curl to fetch a url, it fails - 'curl_exec()' returns nothing. But if I try to execute the same file in CLI - like 'php curl.php', the script works properly. However if I try it in a browser, nothing is returned. The code is...
0
3369
by: xerc | last post by:
I am trying to create a generic function I can call to download all files from a single remote FTP directory -- using CURL. I want to multi-thread it, but need to get the single thread functionality working first before I tackle that. Anyway, in my function I can list all the files, but the function I have, no matter how I try, will only return one file -- the last file. My for() loop seems pretty straightforward, so not sure why only the...
1
4908
by: c1pkw | last post by:
Hi there, I’m having a real heap of trouble with PHP and cURL My aim is to use this code (or something like it) to submit 2 fields to a remote server (using GET) and receive back 6 fields (again with GET). When I run the function below, I get back a 401 unauthorized error although the Username and Password are correct. Presumably then, they are not reaching the remote server at all or in the correct state. Problem is, I know so...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.