Comments (8)
I'm now using a MetadataContext class and it feels right but my first question remains
from bulletphp.
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.
Thanks for the answer. Take your time ;)
from bulletphp.
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.
Aww :(
In App->run(), the App->response() is overwritten. It seems custom response headers are not possible with Bullet.
from bulletphp.
This is a huge issue. Custom headers should absolutely be possible. I will look into this very soon.
from bulletphp.
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.
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)
- Query params available from $app->param('key') but not $app->query('key') HOT 3
- Short-circuit path handling? HOT 9
- Default $method = null for App->run() HOT 1
- Bullet doesn't fully support periods in URIs HOT 3
- Response Handlers cannot be overloaded HOT 3
- http://bulletphp.com/ is down... HOT 4
- Enhancement: Catch-all exception handling HOT 2
- 'Method 'Bullet\App::share' not found' HOT 2
- Path "/" not working in subfolder HOT 8
- set template before $request.isMobile() HOT 1
- $request->param('inputfield','default_value') always return default_value HOT 2
- how use different layout under a same route namespace HOT 1
- Set what format when echo image content in route HOT 3
- Add and document large (chunked) response handling HOT 1
- Document running Bullet from a subdirectory of docroot HOT 1
- composer failing to install HOT 2
- may reversal args that $app->response($1,$2) HOT 1
- Use of deprecated function eregi
- Consider dropping php-5.6 and php-7.0 version supports HOT 5
- Support PHP8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bulletphp.