Subclass of Zlib::Error
When zlib returns a Z_STREAM_END is return if the end of the compressed data has been reached and all uncompressed out put has been produced.
Subclass of Zlib::Error
When zlib returns a Z_STREAM_ERROR, usually if the stream state was inconsistent.
Zlib::ZStream
is the abstract class for the stream which handles the compressed data. The operations are defined in the subclasses: Zlib::Deflate
for compression, and Zlib::Inflate
for decompression.
An instance of Zlib::ZStream
has one stream (struct zstream in the source) and two variable-length buffers which associated to the input (next_in) of the stream and the output (next_out) of the stream. In this document, “input buffer” means the buffer for input, and “output buffer” means the buffer for output.
Data
input into an instance of Zlib::ZStream
are temporally stored into the end of input buffer, and then data in input buffer are processed from the beginning of the buffer until no more output from the stream is produced (i.e. until avail_out
> 0 after processing). During processing, output buffer is allocated and expanded automatically to hold all output data.
Some particular instance methods consume the data in output buffer and return them as a String
.
Here is an ascii art for describing above:
+================ an instance of Zlib::ZStream ================+ || || || +--------+ +-------+ +--------+ || || +--| output |<---------|zstream|<---------| input |<--+ || || | | buffer | next_out+-------+next_in | buffer | | || || | +--------+ +--------+ | || || | | || +===|======================================================|===+ | | v | "output data" "input data"
If an error occurs during processing input buffer, an exception which is a subclass of Zlib::Error
is raised. At that time, both input and output buffer keep their conditions at the time when the error occurs.
Method
Catalogue Many of the methods in this class are fairly low-level and unlikely to be of interest to users. In fact, users are unlikely to use this class directly; rather they will be interested in Zlib::Inflate
and Zlib::Deflate
.
The higher level methods are listed below.
Zlib::GzipWriter
is a class for writing gzipped files. GzipWriter
should be used with an instance of IO
, or IO-like, object.
Following two example generate the same result.
Zlib::GzipWriter.open('hoge.gz') do |gz| gz.write 'jugemu jugemu gokou no surikire...' end File.open('hoge.gz', 'w') do |f| gz = Zlib::GzipWriter.new(f) gz.write 'jugemu jugemu gokou no surikire...' gz.close end
To make like gzip(1) does, run following:
orig = 'hoge.txt' Zlib::GzipWriter.open('hoge.gz') do |gz| gz.mtime = File.mtime(orig) gz.orig_name = orig gz.write IO.binread(orig) end
NOTE: Due to the limitation of Ruby’s finalizer, you must explicitly close GzipWriter
objects by Zlib::GzipWriter#close
etc. Otherwise, GzipWriter
will be not able to write the gzip footer and will generate a broken gzip file.
The InstructionSequence
class represents a compiled sequence of instructions for the Virtual Machine used in MRI. Not all implementations of Ruby may implement this class, and for the implementations that implement it, the methods defined and behavior of the methods can change in any version.
With it, you can get a handle to the instructions that make up a method or a proc, compile strings of Ruby code down to VM instructions, and disassemble instruction sequences to strings for easy inspection. It is mostly useful if you want to learn how YARV works, but it also lets you control various settings for the Ruby iseq compiler.
You can find the source for the VM instructions in insns.def
in the Ruby source.
The instruction sequence results will almost certainly change as Ruby changes, so example output in this documentation may be different from what you see.
Of course, this class is MRI specific.
HTTPGenericRequest is the parent of the Net::HTTPRequest
class.
Do not use this directly; instead, use a subclass of Net::HTTPRequest
.
Response class for URI Too Long
responses (status code 414).
The URI
provided was too long for the server to process.
References:
Response class for URI Too Long
responses (status code 414).
The URI
provided was too long for the server to process.
References:
Response class for Request Header Fields Too Large
responses (status code 431).
An individual header field is too large, or all the header fields collectively, are too large.
References: