Comments (4)
I want to post this to be helpful to anyone finding this thread in case they attempt to test with an text/html content type with UTF-8 charset, because there is a second problem with Nginx's API. If you don't specify the content type length as 9 below, gzip will still fail, because internally nginx is making a hash and then there is no matching hash for this even though text/html works.
The nginx gzip_types directive also does not allow fixing this as far as I can determine. They must have some other code fixing this in other modules since I don't have this problem on my live sites. New modules must have to handle it themselves.
ngx_link_func_write_resp_l(
ctx,
200,
"200 OK",
strlen("200 OK"),
"text/html; charset=utf-8",
9, // we force 9 because nginx doesn't understand how to ignore this part: ; charset=utf-8
buffer,
strlen(buffer)
);
from nginx-link-function.
I provided pull request: #19
from nginx-link-function.
Thanks for your finding, but I am not so sure yet whether is a typo bug from NGINX? As I couldn't find any documentation that this headers_out.content_type_len
been classified as one of the headers_out family. Maybe I was wrong, as Nginx been developed/researched by various product.
ngx_link_func_write_resp_l(
ctx,
200,
"200 OK",
strlen("200 OK"),
"text/html; charset=utf-8",
sizeof("text/html") - 1, // I will suggested you to use this kind of method to count the len for "Hardcoded string" as this is strongly adivised by open source community
buffer,
strlen(buffer)
);
Workaround solution(haven't tested)
- You could install the src/http/ngx_http.h into your header path? And you could make that
content_type_len
updated whenever you need it.
Small note advise, This nginx-link-function is design only for light operation as NGINX is Multi-process single thread IO. And we should not have any heavy process like
- Connection on Connection Model
- Unless you choose for multithread nginx plugin
- Heavy encrypt and decrypt logic
- Unless you choose for multithread nginx plugin
from nginx-link-function.
Yes, I initially had a problem with performance and errors, but then I made use of aio threads, and made sure my ngx_link_func_call was not able to run more then 1 concurrent request per thread. I used the thread id modulus the max threads to lock on a element in an array of mutex to achieve this. After this, I had 60 times better performance without errors, about half the speed of the fastest nginx will run on that machine. It seems like your project is still the best way. The reason I lock like this is to avoid any additional locks in the application. Each thread has its own memory space to do write operations to keep it as lock-free as possible.
from nginx-link-function.
Related Issues (14)
- Could this be somehow used with golang? HOT 6
- How to get the value of a config file param during cycle init? HOT 2
- For windows dll HOT 2
- nginx: [emerg] unknown directive "ngx_http_c_func_link_lib" in /home/aimso/nginx-c-function/t/servroot/conf/nginx.conf HOT 3
- `ngx_link_func_init_cycle()` not found on FreeBSD HOT 12
- Make header installation after building HOT 4
- unknown directive "ngx_link_func_lib" HOT 5
- Facing client request blocking issue? HOT 1
- ngx_http_c_func_module.h not found in your system c header path, please copy latest ngx_http_c_func_module.h to your /usr/include or /usr/local/include HOT 2
- Logging? HOT 2
- Authentication Phase are not support for nginx-c-function with nginx -1.13.3 and below. HOT 1
- how to make an async call before proxy to another server? HOT 1
- How to subrequest in async way by using `ngx_link_func_subrequest ` HOT 1
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 nginx-link-function.