Http
From OpenCA Labs WiKi
[edit]
The HTTP URL
The syntax is as follows:
http://[user[:pwd]@]]address[:port][/path]
where:
- user:pwd : is the user for the web authentication (if any)
- port is the port to connect to. Default is 80
- path is the full path to the resource on the remote server. Default is '/'.
Since version 0.3.0a of LibPKI the HTTP URL supports HTTP redirection and will automatically resolve the redirection and try to access the new URL. The HTTP protocol version is 1.0, and the Connection: close and Host: name headers are used in the GET request. In case of HTTP redirection, the new URL can be any URL supported by the library (i.e., not restricted to HTTP mechanism only).
Here it is an example on how to get data from such a URL:
#include <libpki/pki.h>
int main() {
PKI_MEM_STACK *sk = NULL;
char *url_s = "http://www.openca.org";
if(( sk = URL_get_data( url_s, 0 )) == NULL ) {
printf("ERROR, can not load %s!\n", url_s );
}
printf("Got %d objects!\n", PKI_STACK_MEM_elements(sk));
return(0);
}

