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 595639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:05:04+00:00 2026-05-13T16:05:04+00:00

I want to parse the contents of a dynamic .csv file. However, this code

  • 0

I want to parse the contents of a dynamic .csv file. However, this code (obviously with duff file names, etc.):

$socket = fsockopen("www.example.com", 443);
fwrite($socket, "GET /dynamicCsv.csv?param=value HTTP/1.1\r\n");
fwrite($socket, "Host: www.example.com\r\n");
fwrite($socket, "Connection: close\r\n");
fwrite($socket, "\r\n");

while(!feof($socket)) echo fgets($socket);

…just downloads the file.

Using openssl at command line I can type the exact same request and get the following response header sent back:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-disposition: attachment; filename=dynamicCsv.csv
Pragma: public
Cache-Control: max-age=0
Set-Cookie: SESSIONID=ASDFUHN023UIN0F; Path=/; Secure
Content-Type: text/csv;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 04 Feb 2010 16:53:00 GMT

To avoid having the file download automatically I have tried to chop off the first character using substr, in the hope that maybe the browser sees the response output by fgets as a set of headers of the current document. That didn’t work. Pursuing the same idea I also tried to insert a bunch of newlines before opening the socket, which didn’t work either.

My two questions are:

  1. Why on earth does the browser think it should download the file?
  2. How can I stop it?

I should mention that I’ve only used Chrome so far, but I don’t see why it would make a difference.

Many thanks,
Andreas

  • 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-05-13T16:05:04+00:00Added an answer on May 13, 2026 at 4:05 pm

    Ok, I actually managed to solve it myself. For reference, instead of removing the question I add this response with the fix.

    The problem was that in

    fsockopen("www.example.com", 443);
    

    I did not specify to use the ssl protocol. So the fix is to instead type:

    fsockopen("ssl://www.example.com", 443);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to parse the xml file with dynamic content using DOM parser in
I want to parse a xml file using xquery in Ruby, I found this
I just want the form to read the contents of the .csv file without
I want to parse a html content that have something like this: <div id=sometext>Lorem<br>
I want to parse something like this: Hi [{tagname:content}] [{tag1:xnkudfdhkfujhkdjki diidfo now nested tag
I want to parse xml file in utf-8 and sort it by some field.
I want to parse this CSS Selector (and others of a similar form): div.class1#myid.class2[key=value]
I want to parse a robots.txt file and extract the sitemap reference. Assuming that
I want to parse the following html code for my iphone application <Html> <body>
I want to parse this URL with PHP to get the latitude of a

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.