zlib

How can I catch Zlib::BufError in my Ruby on Rails code?

纵然是瞬间 提交于 2019-12-13 05:53:20
问题 I have built an app with Rails. I have a large list of addresses which I am standardizing via the Bing/Google API using Geocoder. This is my current call to get the adddress info: Geocoder.search(address) This works perfectly fine and I can parse the response JSON. However when I leave the script running it sometimes falls over with the following error: Zlib::BufError: buffer error Instead of the script falling over I would like to catch this error and continue with the script. How could I do

Nginx的基本使用

不打扰是莪最后的温柔 提交于 2019-12-13 04:45:11
一。什么是Nginx 是一款高性能的 http 服务器/反向代理服务器 及 电子邮件( IMAP/POP3)代理服务器, 官方数据支持5万并发,占用资源少,C语言开发。 二。有什么用 个人经历:在公司项目上线本人负责部署项目生产环境的部署,稍微正规点局方都会要求对生产环境管控,不允许我们平时的办公环境直连,但是如果通过linux操作生产环境进行项目调试是很不方便,比如你想测试web前端界面,你还需要登入局方的权限管理平台验证后登入,因为测试环境可以连接生产环境,办公环境又可以连接测试环境,所以我在测试环境搭建了nginx服务器,对生产上部署的web工程和http接口进行反向代理,方便生产的项目调试。 (1)作为普通的http服务器,像tomcat一样 (2)虚拟主机:开启多个端口提供访问服务 (3)反向代理:区别反向和正向代理 (4)负载均衡:多集群进行负载均衡,一般公司的软件负载均衡都是使用的这个。 三。安装部署 (1)注意事项 前面说了nginx是C语言开发的,linux肯定需要gcc编译的,在有些现场环境局方是不会提供root用户,如果服务器维护人员没有安装这些基本的工具那将是一件非常头疼的事,我就遇到那种什么都不给你装的主机。最后你装一个软件就报一个缺少依赖的错,一般主机还不允许连外网,所以你也没办法下,只能本地下好再上传服务器

Decompress DeflateStream (C#) in Delphi

。_饼干妹妹 提交于 2019-12-13 04:38:03
问题 in my application i build a xml structure an send it to a delphi client. In a tag of that xml i have a zipped, base64 coded string: public static string Zip(string text) { byte[] buffer = System.Text.Encoding.Unicode.GetBytes(text); MemoryStream ms = new MemoryStream(); //using (System.IO.Compression.GZipStream zip = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress, true)) //{ // zip.Write(buffer, 0, buffer.Length); //} using (System.IO.Compression

C. Loop compression + send (gzip) ZLIB

吃可爱长大的小学妹 提交于 2019-12-13 03:56:42
问题 I'm currently building an HTTP server in C. Please mind this piece of code : #define CHUNK 0x4000 z_stream strm; unsigned char out[CHUNK]; int ret; char buff[200]; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; int windowsBits = 15; int GZIP_ENCODING = 16; ret = deflateInit2(&strm, Z_BEST_SPEED, Z_DEFLATED, windowsBits | GZIP_ENCODING, 1, Z_DEFAULT_STRATEGY); fill(buff); //fill buff with infos do { strm.next_in = (z_const unsigned char *)buff; strm.avail_in = strlen(buff);

Gzip not working

落爺英雄遲暮 提交于 2019-12-13 03:36:38
问题 I am trying to handle gzip. My sources: zlib,compression,https(article by Rob W) Server-Side: app.get('*', function (req, res, next) { if (req.headers['x-forwarded-proto'] != 'https') { res.setHeader('Content-Type', 'text/event-stream') res.setHeader('Cache-Control', 'no-cache') // send a ping approx every 2 seconds var timer = setInterval(function () { res.write('data: ping\n\n') // !!! this is the important part res.flush() }, 2000) res.on('close', function () { clearInterval(timer) }) res

Determine compressed/uncompressed buffer size for Z-lib in C

こ雲淡風輕ζ 提交于 2019-12-13 03:21:47
问题 I'm using Zlib v1.2.7 to read a text file then compress it and write it to an output file. My problem is in the following example how can I determine the output buffer size based on input size? (in the example gz_length ) I'm using this library for an STM32 Device. I added the unzip method and I have this problem as well for uncompressed data length. #include "zlib.h" int unzip(unsigned char *dst, unsigned long *dst_length, unsigned char *src, unsigned long src_length) { z_stream stream;

Deflate and inflate for PDF, using zlib C++

柔情痞子 提交于 2019-12-13 01:30:03
问题 I am trying to implement the "zlib.h" deflate and inflate functions to compress and decompress streams in PDF-file. Input: compressed stream from PDF-file. I implemented inflate function -- it's all right, I have uncopressed stream, after that I try to compress this stream again with deflate function, as output I have compressed stream, but it is not equal to input compressed stream and they are not equal to the length. What I'm doing wrong? This is a part of my code: size_t outsize =

Redis集群搭建的几种方式

拈花ヽ惹草 提交于 2019-12-12 23:36:25
前面使用了哨兵集群搭建单个分片高可用的结构,实现了主从复制和故障转移,但是没有实现分布式。接下来使用Redis集群搭建,实现哨兵集群没有实现的 分布式 高可用。 redis-cluster搭建需求 下面准备6个redis节点,搭建如图所示的三主三从分布式redis集群,实现两两互联,以master8001为例,它可以连接另外两个主节点,以及三个从节点。搭建过程可以使用原生redis命令,也可以使用ruby自带的脚本(需要先安装ruby)。 ruby脚本辅助搭建 使用ruby脚本辅助安装,即使用redis根目录/src/redis-trib.rb脚本来完成,需要先安装ruby。 -rwxrwxr-x. 1 root root 60852 Sep 21 2017 redis-trib.rb (1)安装ruby,这里解压了压缩包,进行编译和安装。但是安装完只是最基本的一步,后面还需要对ruby进行配置,比较麻烦。 # 解压 [root@node01 /home/software]# tar -zxvf ruby-2.3.1.tar.gz # 检查 [root@node01 /home/software/ruby-2.3.1]# . /configure # 编译,安装 [root@node01 /home/software/ruby-2.3.1]# make && make

Flushing the HTML document early - with ini_set( 'zlib.output_compression','ON')?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 18:45:24
问题 My goal is to early flush the header part of my website while my php script is stitching the rest of the page together and sends it once its done. Important is that the chunks are sent compressed to the browser. (I am using Apache/2.2 and PHP/5.3.4) Right now I am trying to achieve this by calling ini_set("zlib.output_compression", "On") in my PHP script. But if I use flush() anywhere in my script even at the end the compression won't work anymore. Questions are: a) By using this method zlib

Decode gzip compressed and base64 encoded data to a readable format

冷暖自知 提交于 2019-12-12 18:43:09
问题 Trying to decode gzip compressed and base64 encoded data to a readable format in Python3.4. import base64 import zlib original_data = '...jU2X0NCQ19TSEEAAAABAAA=' #Data cut short. decoded64 = base64.b64decode(original_data) #format:b'\x16xe\x94...\xae\x9a\...' final_decoded = zlib.decompress(decoded64) print(final_decoded) Been getting: "Error -2 while preparing to decompress data: inconsistent stream state." Not sure what I'm doing wrong. 回答1: zlib successfully decompresses data that it has