diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-04-27 11:33:32 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-04-27 11:33:32 -0700 |
commit | 8bcf07ce90a9813e3859dce97b4a3a07b43c9cea (patch) | |
tree | 3ba93093481262e81b93e0f63ce1ac665a95a39c | |
parent | 356435e60da0ffc92b4c7a9eb801255f094b4610 (diff) | |
download | kcar-8bcf07ce90a9813e3859dce97b4a3a07b43c9cea.tar.gz |
This function can get intimidating to new users
-rw-r--r-- | ext/kcar/kcar.rl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/kcar/kcar.rl b/ext/kcar/kcar.rl index 5acaa49..e53de45 100644 --- a/ext/kcar/kcar.rl +++ b/ext/kcar/kcar.rl @@ -191,6 +191,12 @@ static void write_value(VALUE hdr, struct http_parser *hp, f = rb_str_new(fptr, flen); v = rb_str_new(vptr, vlen); + /* needs more tests for error-checking here */ + /* + * TODO: + * some of these tests might be too strict for real-world HTTP servers, + * report real-world examples as we find them: + */ if (STR_CSTR_CASE_EQ(f, "connection")) { hp_keepalive_connection(hp, v); } else if (STR_CSTR_CASE_EQ(f, "content-length")) { @@ -240,6 +246,7 @@ static void write_value(VALUE hdr, struct http_parser *hp, e = rb_funcall(hdr, id_sq, 1, f); if (NIL_P(e)) { + /* new value, freeze it since it speeds up MRI slightly */ OBJ_FREEZE(f); if (hclass == rb_cHash) @@ -249,6 +256,13 @@ static void write_value(VALUE hdr, struct http_parser *hp, hp->cont = v; } else { + /* + * existing value, append to it, Rack 1.x uses newlines to represent + * repeated cookies: + * { 'Set-Cookie' => "a=b\nc=d" } + * becomes: + * "Set-Cookie: a=b\r\nSet-Cookie: c=d\r\n" + */ rb_str_buf_cat(e, "\n", 1); hp->cont = rb_str_buf_append(e, v); } |