> Hi, > > I am trying to build an application in C talking the uwsgi protocol > directly with nginx. > > What is supposed to happen when the query is over 65k? > > "datasize" in the "uwsgi_packet_header" is not big enough for it neither > is "val_size" in "uwsgi_var". > > I testing this with nginx and the raw data I receive are: > > 00 5d 02 00 0c 00 51 55 45 52 59 5f 53 54 52 49 . ] . . . . Q U E R > Y _ S T R I > 4e 47 00 00 0e 00 52 45 51 55 45 53 54 5f 4d 45 N G . . . . R E Q U > E S T _ M E > 54 48 4f 44 03 00 47 45 54 0c 00 43 4f 4e 54 45 T H O D . . G E T . > . C O N T E > 4e 54 5f 54 59 50 45 00 00 0e 00 43 4f 4e 54 45 N T _ T Y P E . . . > . C O N T E > 4e 54 5f 4c 45 4e 47 54 48 00 00 0b 00 52 45 51 N T _ L E N G T H . > . . . R E Q > 55 45 53 54 5f 55 52 49 03 00 2f 61 3d 31 32 33 U E S T _ U R I . . > / a = 1 2 3 > 34 35 36 37 38 31 32 33 34 35 36 37 38 31 32 33 4 5 6 7 8 1 2 3 4 5 > 6 7 8 1 2 3 > > The "datasize" is 0x25d = 605 and the "val_size" 0x3 for "REQUEST_URI". > But we see that the actual contents are larger. So it looks like a but in > nginx, however I was wondering what the correct way to encode this using > the uwsgi protocol. > > Thanks, > Steve > > > _______________________________________________ > uWSGI mailing list > [email protected] > http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi >
A whole uwsgi packet must not be bigger than 64k (16bit). The nginx behaviour (letting the value overflow) is expected as in the past the plan was to automatically detect it (overflows are predictable) and manage bigger streams. Currently, as the vast majority of webservers have a default limit (to avoid DOS) that is not larger than 64k, it seems there is no need to manage this. It is a "grey" area, so we are open to suggestions. The policy now (for HTTP requests) is that if you need bigger chunks you should use fastcgi or http. But for RPC, we have a "fallback mode" that supports up to 64bit (this mode is not supported by nginx). There is another approach (easier to implement) to use the first 4 byte headers as a 32bit "total size" buffer. Having said that, the uwsgi protocol is efficient because it is simple (and very limited), very probably adding more logic to it will put it at the same level of fastcgi. uWSGI read the byte 1 and 2 (pktsize) of the header and parses the rest upto pktsize. In case of overflow the stream will be invalid and you will close the connection. You can use another strategy and append an "EOF" keyval to each packet with uwsgi_param UWSGI_EOF ""; and simply parses the tcp stream until you find it (ignoring the pktsize header) -- Roberto De Ioris http://unbit.it _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
