HACKING LICENSE NEWS README
Kcar Parser ParserError RequestEntityTooLargeError RequestURITooLongError Response

Methods

::new #body_bytes_left #body_bytes_left= #body_eof? #chunked? #extract_trailers #filter_body #headers #keepalive? #request #reset #trailers

class Kcar::Parser

Constants

CHUNK_MAX

The maximum size a single chunk when using chunked transfer encoding. This is only a theoretical maximum used to detect errors in clients, it is highly unlikely to encounter clients that send more than several kilobytes at once.

LENGTH_MAX

The maximum size of the body as specified by Content-Length. This is only a theoretical maximum, the actual limit is subject to the limits of the file system used for Dir.tmpdir.

Public Class Methods

Kcar::Parser.new => parser source

Creates a new parser.

call-seq:

parser.reset => parser

Resets the parser so it can be reused by another client

Public Instance Methods

parser.body_bytes_left => nil or Integer source

Returns the number of bytes left to run through Parser#filter_body. This will initially be the value of the "Content-Length" HTTP header after header parsing is complete and will decrease in value as Parser#filter_body is called for each chunk. This should return zero for responses with no body.

This will return nil on "Transfer-Encoding: chunked" responses as well as HTTP/1.0 responses where Content-Length is not set

parser.body_bytes_left = Integer source

Sets the number of bytes left to download for HTTP responses with "Content-Length". This raises RuntimeError for chunked responses.

parser.body_eof? => true or false source

Detects if we're done filtering the body or not. This can be used to detect when to stop calling Parser#filter_body.

parser.chunked? => true or false source

This is used to detect if a response uses chunked Transfer-Encoding or not.

extract_trailers (hdr) source

extract trailers that were set in the header object as an array of arrays

parser.extract_trailers(hdr) =>
    [ [ 'Content-MD5', '1B2M2Y8AsgTpgAmY7PhCfg==' ] ]
parser.filter_body(dst, src) => nil/dst source

Takes a String of src, will modify src if dechunking is done. Returns nil if there is more src left to process. Returns dst if body processing is complete. When returning dst, it may modify src so the start of the string points to where the body ended so that trailer processing can begin.

Raises ParserError if there are dechunking errors. Basically this is a glorified memcpy(3) that copies src into dst while filtering it through the dechunker.

parser.headers(hdr, data) => hdr or nil source

Takes a Hash and a String of data, parses the String of data filling in the Hash returning the Hash if parsing is finished, nil otherwise When returning the hdr Hash, it may modify data to point to where body processing should begin.

Raises ParserError if there are parsing errors.

parser.keepalive? => true or false source

This should be used to detect if a request can really handle keepalives and pipelining. Currently, the rules are:

  1. MUST be HTTP/1.1 or HTTP/1.0 with "Connection: keep-alive"

  2. MUST NOT have "Connection: close" set

  3. If there is a response body, either a) Content-Length is set or b) chunked encoding is used

request (p1, p2) source
parser.reset => parser source

Resets the parser so it can be reused by another client

parser.headers(hdr, data) => hdr or nil source

Takes a Hash and a String of data, parses the String of data filling in the Hash returning the Hash if parsing is finished, nil otherwise When returning the hdr Hash, it may modify data to point to where body processing should begin.

Raises ParserError if there are parsing errors.


Pages Classes Methods
mail archives: https://yhbt.net/kcar-public/
	http://ou63pmih66umazou.onion/kcar-public/ 
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.kcar 
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.kcar 
public: kcar-public@yhbt.net
source code: git clone https://yhbt.net/kcar.git
	torsocks git clone http://ou63pmih66umazou.onion/kcar.git