CURLOPT_HEADER returns 401

Posted on 2014-09-25
Medium Priority
Last Modified: 2014-10-01
I need to get the location header. From what I've read, this should be as simple as

curl_setopt($c, CURLOPT_HEADER, true);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, false);

Open in new window

If I don't include those two options, the curl request works fine, but I'm not able to get the location header.

If I do include those two options, then I get a 401 error.

The Location that is being returned should be a URL that does require an additional login. What am I doing wrong?
Question by:quizwedge
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 35

Assisted Solution

gr8gonzo earned 1000 total points
ID: 40344907
The 401 code isn't an error. It's just the code that tells the browser to prompt for authentication. Are you looking for a URL that happens AFTER login?
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 40344924
By themselves, these two instructions don't tell us much.  What is the URL you're making the request to?  Why are you telling cURL not to follow the location headers?
LVL 14

Accepted Solution

quizwedge earned 0 total points
ID: 40346289
In generating the needed information for a response, I figured out my issue. I wasn't thinking about previous requests. Looking too much at the trees to see the forest.

I have to make a call to get a session token and then use that session token to make my PUT call. Since I wasn't parsing out the headers from the previous request, I wasn't successfully grabbing the session token. Everything is working now.
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

LVL 14

Author Comment

ID: 40346466
I've requested that this question be closed as follows:

Accepted answer: 0 points for quizwedge's comment #a40346289

for the following reason:

The issue was a previous request. I didn't have enough information in the question to allow others to provide an answer and once I got that information, I was able to find the solution.
LVL 35

Expert Comment

ID: 40346327
If our questions prompted you in a direction that led to the correct answer, I would consider awarding points to those comments.
LVL 14

Author Comment

ID: 40346467
It wasn't any one question that prompted me, but I'll split points.
LVL 14

Author Closing Comment

ID: 40354165
The issue was a previous request. I didn't have enough information in the question to allow others to provide an answer and once I got that information, I was able to find the solution.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question