sendfile

[转]Battle ready Nginx

橙三吉。 提交于 2019-12-05 03:08:37
Battle ready Nginx - an optimization guide Most setup guides for Nginx tell you the basics - apt-get a package, modify a few lines here and there, and you’ve got a web server! And, in most cases, a vanilla nginx install will work just fine for serving your website. However, if you’re REALLY trying to squeeze performance out of nginx, you’ll have to go a few steps further. In this guide, I’ll explain which settings in nginx can be fine tuned in order to optimize performance for handling a large number of clients. As a note, this isn’t a comprehensive guide for fine-tuning. It’s a breif overview

swift, send file to server

我们两清 提交于 2019-12-04 10:30:04
问题 I am learning swift and I send a request to the server with the code below. It works for simple request and I get response from the server. My problem is I can not send a file to server. code : let parameters = parameter let request = NSMutableURLRequest(URL: NSURL(string: requestUrl)!) let boundaryConstant = "-----Boundary+\(arc4random())\(arc4random())" let contentType = "multipart/form-data; boundary=" + boundaryConstant let boundaryStart = "--\(boundaryConstant)\r\n" let boundaryEnd = "--

sendfile64 only copy about 2GB

为君一笑 提交于 2019-12-04 07:15:51
I need to use sendfile64 to copy about 16GB of files. What I have achieved so far is #include <unistd.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/sendfile.h> #include <sys/stat.h> int main (int argc, char** argv) { long long src; long long dest; struct stat64 stat_buf; off64_t offset = 0LL; long long rc; if (argc != 3) { fprintf(stderr, "usage: %s <source> <destination>\n", argv[0]); exit(1); } src = open64(argv[1], O_RDONLY); if (src == -1) { fprintf(stderr, "unable to open '%s': %s\n", argv[1], strerror(errno)); exit(1); }

Rails 4, asset pipeline causes user downloadable files to be downloaded twice

别说谁变了你拦得住时间么 提交于 2019-12-04 01:44:40
问题 I have a folder in my app directory named "uploads" where users can upload files and download files. I don't want the uploads folder to be in the public directory because I want to control download authorization. In my controller, I have: send_file Rails.root.join('app', 'uploads', filename), :type => 'application/zip', :disposition => 'inline', :x_sendfile=>true This actually works fine. The problem is that when I'm on the production server, when I run the rake assets:precompile, and have an

Django and Nginx X-accel-redirect

你离开我真会死。 提交于 2019-12-04 01:41:57
问题 I have been fumbling around with trying to protect Django's media files with no luck so far! I am simply trying to make it where ONLY admin users can access the media folder. Here is my Nginx file. server { listen 80; server_name xxxxxxxxxx; location = /favicon.ico {access_log off; log_not_found off;} location /static/ { alias /home/{site-name}/static_cdn/; } location /media/ { internal; root /home/{site-name}/; } location / { this is setup and working. Didn't include Code though } My Url

send_file just sends an empty file

情到浓时终转凉″ 提交于 2019-12-03 23:58:44
问题 Im looking for a way to download a xml file. I use: file_path = 'folder/' + xml_name + '.xml' send_file file_path, :type => "text/xml" but this always downloads me an empty file. The file itself has 16 KB of data in it... why is that? Maechi 回答1: probably you have to comment out config.action_dispatch.x_sendfile_header = "X-Sendfile" in production.rb see http://vijaydev.wordpress.com/2010/12/15/rails-3-and-apache-x-sendfile/ for explanations 回答2: Problem saved, but I don't know why File.open

express: how to send html together with css using sendFile?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 08:52:28
问题 var app = require('express')(); app.get('/', function(req, res) { res.sendFile(__dirname + "/" + "index.html"); }); <link rel="stylesheet" href="style.css"> I used the above node.js code to send a html file. To get the html file formatted I need to send another css file(style.css). My question is: how can I send both of these two files(index.html and style.css) using sendFile() and integrate them together in the client side? 回答1: The browser should load style.css on its own, so you can serve

C, sendfile() and send() difference?

牧云@^-^@ 提交于 2019-12-03 04:25:10
问题 sendfile() copies data between two file descripters within kernel space. Somewhere I saw if you are writing a web server in C in linux you should use send() and recv() instead of using write() and read(). So is the send() use the kernel space as well? Whatever I use for sending - sendfile() or send() - on the client side I'll be using recv() right? On the flip side, man page says: "The only difference between send() and write(2) is the presence of flags. With a zero flags argument, send() is

Minimizing copies when writing large data to a socket

强颜欢笑 提交于 2019-12-03 03:45:52
I am writing an application server that processes images (large data). I am trying to minimize copies when sending image data back to clients. The processed images I need to send to clients are in buffers obtained from jemalloc. The ways I have thought of sending the data back to the client is: 1) Simple write call. // Allocate buffer buf. // Store image data in this buffer. write(socket, buf, len); 2) I obtain the buffer through mmap instead of jemalloc, though I presume jemalloc already creates the buffer using mmap. I then make a simple call to write. buf = mmap(file, len); // Imagine

C, sendfile() and send() difference?

空扰寡人 提交于 2019-12-02 18:43:17
sendfile() copies data between two file descripters within kernel space. Somewhere I saw if you are writing a web server in C in linux you should use send() and recv() instead of using write() and read(). So is the send() use the kernel space as well? Whatever I use for sending - sendfile() or send() - on the client side I'll be using recv() right? On the flip side, man page says: "The only difference between send() and write(2) is the presence of flags. With a zero flags argument, send() is equivalent to write(2)." If fd is a socket file descriptor, then these system calls are identical: send