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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:36:56+00:00 2026-06-05T01:36:56+00:00

Quite simply, I’m trying to generate and download a CSV file from a CakePHP

  • 0

Quite simply, I’m trying to generate and download a CSV file from a CakePHP controller. No problem generating the CSV, and everything works until the response >= 4096 bytes.

The following controller illustrates the problem:

class TestTypeController extends Controller {
  public function csv($size = 100) {
    # set the content type
    Configure::write('debug', 0);
    $this->autoRender = false;
    $this->response->type('csv');
    # send the response
    for ($i = 0; $i < $size; $i++)
      echo 'x';
  }
}

When I call http://baseurl/test_type/csv/4095, I’m prompted to save the file, and the Content-Type header is text/csv. The response headers are:

HTTP/1.1 200 OK
Date: Tue, 05 Jun 2012 14:28:56 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.1
Content-Length: 4095
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: text/csv; charset=UTF-8

When I call http://baseurl/test_type/csv/4096, the file is printed to the screen, and the response headers are:

HTTP/1.1 200 OK
Date: Tue, 05 Jun 2012 14:28:53 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.1
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 38
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

Obviously, 4kB is the limit where Content-Encoding starts gzipping the response. I’m not familiar with how the Content-Type is meant to react, but I’d obviously prefer it to remain text/csv.

The same problem occurs using the RequestHandlerComponent to manage the type of the response.

I’m using the CakePHP 2.2.0-RC1, but I’ve verified the problem exists with stable 2.1.3. Any ideas? Pointers in the right direction?

  • 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-05T01:36:58+00:00Added an answer on June 5, 2026 at 1:36 am

    The answer was pretty simple — the controller should be returning the CSV data instead of echoing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quite simply, how do I push a new view controller from a prototype cell
This is quite frustrating. I am simply trying to create a dynamic text and
I have a SQL query that is quite simply select * from tblOrders where
Quite simply, can one instance of javax.crypto.Cipher (e.g. Cipher.getInstance(RSA) ) be used from multiple
Quite simply, is such a query/statement inefficient or bad? <? $strSql=SELECT * FROM clients,
Quite simply, I have the following query $q = SELECT fixture_date FROM .TBL_FOOT_GAMES. WHERE
Quite simply, I'm trying to connect to a MongoDB via Node.js: Db = require('../v2/node_modules/mongodb').Db
Quite simply: File account = new File(./data/account); account.createNewFile(); Gives me: java.io.IOException: No such file
Quite simply, given a sequence in F#, how does one obtain elements from index
Quite simply: is there a place such as DeviantArt, but purely for the purpose

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.