1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2013 Index Data
3 * See the file LICENSE for details.
14 #include <yaz/comstack.h>
15 #include <yaz/tcpip.h>
18 static void tst_http_response(void)
20 /* response, content */
21 const char *http_buf =
22 /*123456789012345678 */
24 "Content-Length: 2\r\n"
30 ODR enc = odr_createmem(ODR_ENCODE);
31 ODR dec = odr_createmem(ODR_DECODE);
32 odr_setbuf(dec, (char *) http_buf, strlen(http_buf), 0);
33 r = z_GDU(dec, &zgdu, 0, 0);
39 YAZ_CHECK_EQ(zgdu->which, Z_GDU_HTTP_Response);
41 zgdu->u.HTTP_Response->content_len = 1;
42 /* we now have Content-Length=2, but content_len=1 */
43 z_GDU(enc, &zgdu, 0, 0);
44 http_buf1 = odr_getbuf(enc, &http_len1, 0);
48 const char *http_buf2 =
49 /*123456789012345678 */
51 "Content-Length: 1\r\n" /* content_len takes precedence */
54 YAZ_CHECK_EQ(http_len1, strlen(http_buf2));
55 YAZ_CHECK(http_len1 == strlen(http_buf2) &&
56 memcmp(http_buf1, http_buf2, http_len1) == 0);
64 int main (int argc, char **argv)
66 YAZ_CHECK_INIT(argc, argv);
75 * c-file-style: "Stroustrup"
76 * indent-tabs-mode: nil
78 * vim: shiftwidth=4 tabstop=8 expandtab