Comments (5)
I see. Yeah, this case requires constness to be cast.
Out of curiosity, what it the use case of REQUEST_COMPLETE? Can't you do the work in NEW_REQUEST handler, cause you know it is going to be 304 ?
from mongoose.
The use case is "standardized" access logs. I write to the log twice. When new_request arrives and when request_complete arrives so I can list durations and stuff in the second log action. This applies to both requests I handle and which are handled internally (mostly images/js/css files).
Written in a format similar to Apache, I can use logging tools for Apache to examine my logs for long processes (not that I've gotten that sophisticated with it yet).
from mongoose.
I see. The problem is that I am mixing two things together - request info,
which must be const, and reply info (status code).
I'd like to keep request_info const, cause that sounds right. user_data can
be taken out from there and a different call could be made,
e.g. mg_get_user_data() to retrieve it.
Not sure what to do with status code though. Ideas?
Do you thing it is cleaner to remove constness from the request_info ?
On Wed, Sep 5, 2012 at 7:15 PM, jmucchiello [email protected]:
The use case is "standardized" access logs. I write to the log twice. When
new_request arrives and when request_complete arrives so I can list
durations and stuff in the second log action. This applies to both requests
I handle and which are handled internally (mostly images/js/css files).Written in a format similar to Apache, I can use logging tools for Apache
to examine my logs for long processes (not that I've gotten that
sophisticated with it yet).—
Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-8308269.
from mongoose.
I understand wanting to make request_info const. So do I. But that status code gets in the way. Since it is just status code and user_data, you could add two APIs. A mg_get_user_data(conn) API is simple. For status_code, you may as well have it send the status_code as well: mg_send_status_code(conn, int status_code, const char* status_text).
Internally mg_send_status_code() would set the status_code in the request structure and call mg_printf with the first line HTTP response:
mg_printf("HTTP/1.1 %d %s", status_code, status_text);
I "nicer" version of such a function would supply the status_text based on the status_code but for a first run API, this should be good enough.
Ultimately it depends on how much want the request info to be const compared to how much you dislike adding APIs to mongoose.
from mongoose.
Issue 15 is very relevant. Let's close this and proceed with issue 15.
from mongoose.
Related Issues (20)
- How to upload a file by https?(device-dashboard) HOT 3
- [Question] How to protect server from OOM attack HOT 1
- Facing issue in accessing FLASH_SIZE register on the STM32H7 HOT 4
- Is it save to call free() after passing data to mg_ws_send()? HOT 5
- When using Mbed TLS, not all data will be processed. HOT 23
- Coverity - Unchecked return value, send may fail. HOT 1
- Coverity - truncated cast. HOT 1
- Coverity - Out-of-bounds-access HOT 1
- support for openssl-3 HOT 4
- Handshake with TLS 1.3 server fails using MbedTLS HOT 8
- PHP support?
- ArmHF unit tests fail with warnings in tls_builtin
- S390 test gets stuck after WS with tls_builtin
- QoS1 and QoS2 cannot be implemented with the API HOT 18
- visual studio compile mongoose.c report warning C4267: convert size_t to int HOT 1
- MacOS unit tests fail with MbedTLS HOT 7
- Is it possible to add the mg_mqtt_unsub function? HOT 3
- mqtt: Unable to set zero-length Will message
- how can we access fn_data from mg_http_listen's callback funtion (mg_event_handler_t) ? HOT 3
- [Request feature] can you support wolfssl library HOT 3
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 mongoose.