Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:24:14+00:00 2026-06-09T05:24:14+00:00

I don’t know how to write a better title. Feel free to edit. Somehow

  • 0

I don’t know how to write a better title. Feel free to edit. Somehow I didn’t find anything on this:

I have a cURL request from PHP which returns a quicktime file. This works fine if I want to output the stream in the browser’s window. But I want to send it as it were a real file. How can I pass the headers and set it to the script’s output, without the need of storing everything in a variable.

The script looks like this:

if (preg_match('/^[\w\d-]{36}$/',$key)) {

    // create url
    $url        = $remote . $key;

    // init cURL request
    $ch         = curl_init($url);

    // set options
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
    curl_setopt($ch, CURLOPT_NOBODY, false);
    curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
    if (null !== $username) {
        curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
    }

    // execute request
    curl_exec($ch);

    // close
    curl_close($ch);
}

I can see the header and content like this, so the request itself is working fine:

HTTP/1.1 200 OK X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2 Java/Oracle Corporation/1.7) Server: GlassFish Server Open Source Edition 3.1.2 Content-Type: video/quicktime Transfer-Encoding: chunked

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:24:16+00:00Added an answer on June 9, 2026 at 5:24 am

    So with the help of the previous answers I got it to work. Still it has one request to much in my opinion, but maybe someone has a better approach.

    The problems that occurred where:

    1.) When using cURL like this:

    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    

    the header didn’t return the content-type, but only *\*.

    2.) Using curl_setopt($ch, CURLOPT_NOBODY, false); got the right content-type but also the whole content itself. So I could store everything in a variable, read the header, send the content. Not really an option somehow.

    So I had to request the header once using get_headers($url, 1); before getting the content.

    3.) Finally, there was the problem that the HTML5-video-tag and the jwPlayer both didn’t want to play ‘index.php’. So with mod_rewrite and setting ‘name.mov’ to ‘index.php’ it worked:

    RewriteRule ^(.*).mov index.php?_route=$1 [QSA]
    

    This is the result:

    if (preg_match('/^[\w\d-]{36}$/',$key)) {
    
        // create url
        $url        = $remote . $key;
    
        // get header
        $header     = get_headers($url, 1);
    
        if ( 200 == intval(substr($header[0], 9, 3)) ) {
            // create url
            $url        = $remote . $key;
    
            // init cURL request
            $ch         = curl_init($url);
    
            // set options
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
            curl_setopt($ch, CURLOPT_NOBODY, false);
            curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
            if (null !== $username) {
                curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
            }
    
            // set header
            header('Content-Type: ' . $header['Content-Type']);
    
            // execute request
            curl_exec($ch);
    
            // close
            curl_close($ch);
    
            exit();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

don't know better title for this, but here's my code. I have class user
Don't know why but I can't find a solution to this. I have 3
don't know if the title describes anything about what I'm trying to say but
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this has been answered before. Have custom routes to users. If
Don't know if there is a better way to do this, so that is
Don't know a better title but here is what im trying to do. I
I don't know to explain this but here i go, so i have a
Don't really know how to formulate the title, but it should be pretty obvious
I don't know why, but this code worked for me a month ago... maybe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.