summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar snowdrop2003-12-18 12:23:44 +0000
committerGravatar snowdrop2003-12-18 12:23:44 +0000
commitdaf0f849fd34c6c626b4ff469fa59fb1b55974de (patch)
treeb8e4e6f42a37c744606f50c097ba16ccbd036222
parentef184dc4c57cf56643c3446e7d527b4ab0bc7df6 (diff)
downloadcsoap-daf0f849fd34c6c626b4ff469fa59fb1b55974de.tar.gz
csoap-daf0f849fd34c6c626b4ff469fa59fb1b55974de.tar.bz2
added hpairnode_get_ignore_case() and used in httpc_talk_to_server()
-rw-r--r--config.h.in6
-rw-r--r--examples/nanohttp/httpget.c4
-rw-r--r--examples/nanohttp/httpgetcb.c5
-rw-r--r--nanohttp/nanohttp-client.c4
-rw-r--r--nanohttp/nanohttp-common.c44
-rw-r--r--nanohttp/nanohttp-common.h11
6 files changed, 67 insertions, 7 deletions
diff --git a/config.h.in b/config.h.in
index 7b39ea8..2e100bd 100644
--- a/config.h.in
+++ b/config.h.in
@@ -72,6 +72,12 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
/* Version number of package */
#undef VERSION
diff --git a/examples/nanohttp/httpget.c b/examples/nanohttp/httpget.c
index 3ace8c2..4eab70e 100644
--- a/examples/nanohttp/httpget.c
+++ b/examples/nanohttp/httpget.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: httpget.c,v 1.1 2003/12/11 14:52:14 snowdrop Exp $
+ * $Id: httpget.c,v 1.2 2003/12/18 12:23:44 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003 Ferhat Ayaz
@@ -37,6 +37,8 @@ int main(int argc, char *argv[])
exit(1);
}
+ log_set_level(HLOG_VERBOSE);
+
conn = httpc_new();
res = httpc_get(conn, argv[1]);
diff --git a/examples/nanohttp/httpgetcb.c b/examples/nanohttp/httpgetcb.c
index 1f2ca8f..94f5b9c 100644
--- a/examples/nanohttp/httpgetcb.c
+++ b/examples/nanohttp/httpgetcb.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: httpgetcb.c,v 1.1 2003/12/11 14:52:14 snowdrop Exp $
+ * $Id: httpgetcb.c,v 1.2 2003/12/18 12:23:44 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003 Ferhat Ayaz
@@ -39,7 +39,7 @@ void my_start_callback(httpc_conn_t *conn, void *userdata,
pair = header;
while (pair != NULL) {
- log_debug3("%s: %s", pair->key, pair->value);
+ log_debug3("%s: '%s'", pair->key, pair->value);
pair = pair->next;
}
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
}
conn = httpc_new();
+ /* httpc_set_header(conn, HEADER_TRANSFER_ENCODING, "chunked");*/
httpc_get_cb(conn, argv[1], my_start_callback, my_callback, NULL);
httpc_free(conn);
diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c
index 14b024f..f670c71 100644
--- a/nanohttp/nanohttp-client.c
+++ b/nanohttp/nanohttp-client.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-client.c,v 1.5 2003/12/18 11:14:37 snowdrop Exp $
+ * $Id: nanohttp-client.c,v 1.6 2003/12/18 12:23:44 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -375,7 +375,7 @@ int httpc_talk_to_server(hreq_method method, httpc_conn_t *conn, const char *url
/* Check if server communicates with content-length */
content_length_str =
- hpairnode_get(res->header, HEADER_CONTENT_LENGTH);
+ hpairnode_get_ignore_case(res->header, HEADER_CONTENT_LENGTH);
if (content_length_str != NULL) {
diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c
index 4c196a9..d7396d6 100644
--- a/nanohttp/nanohttp-common.c
+++ b/nanohttp/nanohttp-common.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-common.c,v 1.4 2003/12/18 11:14:37 snowdrop Exp $
+ * $Id: nanohttp-common.c,v 1.5 2003/12/18 12:23:44 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -106,6 +106,29 @@ void log_error(const char* FUNC, const char *format, ...)
}
+/* -----------------------------------------
+ FUNCTION: strcmpigcase
+ ------------------------------------------ */
+int strcmpigcase(const char *s1, const char *s2)
+{
+ int l1, l2, i;
+
+ if (s1 == NULL && s2 == NULL) return 1;
+ if (s1 == NULL || s2 == NULL) return 0;
+
+ l1 = strlen(s1);
+ l2 = strlen(s2);
+
+ if (l1 != l2) return;
+
+ for (i=0;i<l1;i++)
+ if (toupper(s1[i]) != toupper(s2[i]))
+ return 0;
+
+ return 1;
+}
+
+
hpair_t *hpairnode_new(const char* key, const char* value, hpair_t *next)
{
hpair_t *pair;
@@ -232,6 +255,25 @@ void hpairnode_free(hpair_t *pair)
}
+char *hpairnode_get_ignore_case(hpair_t *pair, const char* key)
+{
+ if (key == NULL) {
+ log_error1("key is NULL");
+ return NULL;
+ }
+
+ while (pair != NULL) {
+ if (pair->key != NULL) {
+ if (strcmpigcase(pair->key, key)) {
+ return pair->value;
+ }
+ }
+ pair = pair->next;
+ }
+
+ return NULL;
+}
+
char *hpairnode_get(hpair_t *pair, const char* key)
{
if (key == NULL) {
diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h
index 326a4e4..79db58b 100644
--- a/nanohttp/nanohttp-common.h
+++ b/nanohttp/nanohttp-common.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-common.h,v 1.4 2003/12/18 11:14:37 snowdrop Exp $
+ * $Id: nanohttp-common.h,v 1.5 2003/12/18 12:23:44 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -38,6 +38,14 @@
#define SAVE_STR(str) ((str==0)?("(null)"):(str))
#endif
+
+/*
+ string function to compare strings ignoring case
+ Returns 1 if s1 equals s2 and 0 otherwise.
+ */
+int strcmpigcase(const char *s1, const char *s2);
+
+
/*
hpairnode_t represents a pair (key, value) pair.
This is also a linked list.
@@ -54,6 +62,7 @@ struct hpair
hpair_t *hpairnode_new(const char* key, const char* value, hpair_t* next);
void hpairnode_free(hpair_t *pair);
char *hpairnode_get(hpair_t *pair, const char* key);
+char *hpairnode_get_ignore_case(hpair_t *pair, const char* key);
hpair_t* hpairnode_copy(const hpair_t *src);
hpair_t* hpairnode_copy_deep(const hpair_t *src);
void hpairnode_dump_deep(hpair_t *pair);