int hc_rtp_multicast:1;
long hc_rtsp_stream_id;
int hc_rtp_timeout;
+ char *hc_rtsp_user;
+ char *hc_rtsp_pass;
struct http_client_ssl *hc_ssl; /* ssl internals */
int http_client_send( http_client_t *hc, http_cmd_t cmd,
const char *path, const char *query,
http_arg_list_t *header, void *body, size_t body_size );
+void http_client_basic_auth( http_client_t *hc, http_arg_list_t *h,
+ const char *user, const char *pass );
int http_client_simple( http_client_t *hc, const url_t *url);
int http_client_clear_state( http_client_t *hc );
int http_client_run( http_client_t *hc );
goto retry;
}
+/*
+ *
+ */
+void
+http_client_basic_auth( http_client_t *hc, http_arg_list_t *h,
+ const char *user, const char *pass )
+{
+ if (user && user[0] && pass && pass[0]) {
+#define BASIC "Basic "
+ size_t plen = strlen(pass);
+ size_t ulen = strlen(user);
+ size_t len = BASE64_SIZE(plen + ulen + 1) + 1;
+ char *buf = alloca(ulen + 1 + plen + 1);
+ char *cbuf = alloca(len + sizeof(BASIC) + 1);
+ strcpy(buf, user);
+ strcat(buf, ":");
+ strcat(buf, pass);
+ strcpy(cbuf, BASIC);
+ base64_encode(cbuf + sizeof(BASIC) - 1, len,
+ (uint8_t *)buf, ulen + 1 + plen);
+ http_arg_set(h, "Authorization", cbuf);
+#undef BASIC
+ }
+}
+
/*
* Redirected
*/
}
if (!keepalive)
http_arg_set(h, "Connection", "close");
- if (url->user && url->user[0] && url->pass && url->pass[0]) {
-#define BASIC "Basic "
- size_t plen = strlen(url->pass);
- size_t ulen = strlen(url->user);
- size_t len = BASE64_SIZE(plen + ulen + 1) + 1;
- char *buf = alloca(ulen + 1 + plen + 1);
- char *cbuf = alloca(len + sizeof(BASIC) + 1);
- strcpy(buf, url->user);
- strcat(buf, ":");
- strcat(buf, url->pass);
- strcpy(cbuf, BASIC);
- base64_encode(cbuf + sizeof(BASIC) - 1, len,
- (uint8_t *)buf, ulen + 1 + plen);
- http_arg_set(h, "Authorization", cbuf);
-#undef BASIC
- }
+ http_client_basic_auth(hc, h, url->user, url->pass);
}
static int
free(hc->hc_host);
free(hc->hc_scheme);
free(hc->hc_bindaddr);
+ free(hc->hc_rtsp_user);
+ free(hc->hc_rtsp_pass);
free(hc);
}
}
http_arg_set(hdr, "Session", hc->hc_rtsp_session);
}
+ http_client_basic_auth(hc, hdr, hc->hc_rtsp_user, hc->hc_rtsp_pass);
if (hc->hc_port != 554)
snprintf(buf2, sizeof(buf2), ":%d", hc->hc_port);
else