Code Monkey home page Code Monkey logo

Comments (8)

seblucas avatar seblucas commented on June 8, 2024

I'm now using a MetadataContext class and it feels right but my first question remains

from bulletphp.

vlucas avatar vlucas commented on June 8, 2024

Seems like you should be able to set headers before sending a response - that definitely breaks my expectations as well. I won't have a chance to dig into this for another few days, but this definitely seems like a bug.

from bulletphp.

seblucas avatar seblucas commented on June 8, 2024

Thanks for the answer. Take your time ;)

from bulletphp.

acicali avatar acicali commented on June 8, 2024

Judging by the first lines of function header in response.php adding headers is impossible if the response has no content. Is there a reason why ?

I don't believe this is the case. The $content parameter is meant to accept the value of the header, not the response body. The first few lines of Response->header() are checking to see if a value was provided, and if not, it returns the value of that header (or false if it hasn't been set). In this way, the header() function acts as a setter() and getter(), which is a common pattern.

Example:

$response->header('X-Total-Count', 20); //set the 'X-Total-Count' header

$total = $response->header('X-Total-Count'); //returns '20'

The third parameter specifies what the setter() should do if the header already exists (true replaces it, false duplicates it).

Please issue lashings if I'm incorrect. :)

from bulletphp.

acicali avatar acicali commented on June 8, 2024

Aww :(

In App->run(), the App->response() is overwritten. It seems custom response headers are not possible with Bullet.

from bulletphp.

vlucas avatar vlucas commented on June 8, 2024

This is a huge issue. Custom headers should absolutely be possible. I will look into this very soon.

from bulletphp.

acicali avatar acicali commented on June 8, 2024

I shouldn't have said "not possible". One can simply use the native PHP header() function before sending any output.

More accurately, it appears _to me_ that Response->header() cannot be used to send custom response header.

from bulletphp.

netom avatar netom commented on June 8, 2024

Solved, see AppTest::testSupportCustomHeaders(). Commit b4b1dd7 make Response::content() fluent, and makes it easy to build and return a response in a single expression.

from bulletphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.