/*-------------------------------------------------- FUNCTION: httpc_set_header DESC: Adds a new (key, value) pair to the header or modifies the old pair if this function will finds another pair with the same 'key' value. ----------------------------------------------------*/ int httpc_set_header(httpc_conn_t *conn, const char *key, const char *value) { hpair_t *p; if (conn == NULL) { log_warn1("Connection object is NULL"); return 0; } for (p = conn->header; p; p = p->next) { if (p->key && !strcmp(p->key, key)) { free(p->value); p->value = strdup(value); return 1; } } conn->header = hpairnode_new(key, value, conn->header); return 0; }
int httpc_add_header(httpc_conn_t *conn, const char *key, const char *value) { if (!conn) { log_warn1("Connection object is NULL"); return -1; } conn->header = hpairnode_new(key, value, conn->header); return 0; }
herror_t hssl_server_ssl(hsocket_t * sock) { SSL *ssl; int ret; BIO *sbio; if (!enabled) return H_OK; log_verbose2("Starting SSL initialization for socket %d", sock->sock); if (!(ssl = SSL_new(context))) { log_warn1("SSL_new failed"); return herror_new("hssl_server_ssl", HSSL_ERROR_SERVER, "Cannot create SSL object"); } /* SSL_set_fd(ssl, sock->sock); */ sbio = BIO_new_socket(sock->sock, BIO_NOCLOSE); if (sbio == NULL) { log_error1("BIO_new_socket failed"); return NULL; } // BIO_set_callback(sbio, hssl_bio_cb); sbio->method->bread = _hssl_bio_read; SSL_set_bio(ssl, sbio, sbio); if ((ret = SSL_accept(ssl)) <= 0) { herror_t err; log_error2("SSL_accept failed (%s)", _hssl_get_error(ssl, ret)); err = herror_new("hssl_server_ssl", HSSL_ERROR_SERVER, "SSL_accept failed (%s)", _hssl_get_error(ssl, ret)); SSL_free(ssl); return err; } sock->ssl = ssl; return H_OK; }
void httpc_add_headers(httpc_conn_t *conn, const hpair_t *values) { if (conn == NULL) { log_warn1("Connection object is NULL"); return; } for ( ;values; values=values->next) httpc_add_header(conn, values->key, values->value); return; }
char * soap_env_find_urn(SoapEnv * env) { xmlNsPtr ns; xmlNodePtr body, node; if (!(body = soap_env_get_body(env))) { log_verbose1("body is NULL"); return 0; } /* node is the first child */ if (!(node = soap_xml_get_children(body))) { log_error1("No namespace found"); return 0; } /* if (node->ns && node->ns->prefix) MRC 1/25/2006 */ if (node->ns) { ns = xmlSearchNs(body->doc, node, node->ns->prefix); if (ns != NULL) { return((char *) ns->href); /* namespace found! */ } } else { static char *empty = ""; log_warn1("No namespace found"); return(empty); } return 0; }