mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-03 08:01:25 +08:00
f423f27693
This supports better authorization handling for DAP requests, especially redirection based authorization. I also added a new test case ncdap_tests/testauth.sh. Specifically, suppose I have a netrc file /tmp/netrc containing this. machine uat.urs.earthdata.nasa.gov login xxxxxx password yyyyyy Also suppose I have a .ocrc file containing these lines HTTP.COOKIEJAR=/tmp/cookies HTTP.NETRC=/tmp/netrc Assume that .ocrc is in the local directory or HOME. Then this command should work (assuming a valid login and password). ncdump -h "https://54.86.135.31/opendap/data/nc/fnoc1.nc"
60 lines
2.0 KiB
C
60 lines
2.0 KiB
C
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
|
See the COPYRIGHT file for more information. */
|
|
|
|
#ifndef OCURI_H
|
|
#define OCURI_H
|
|
|
|
/*! This is an open structure meaning
|
|
it is ok to directly access its fields*/
|
|
typedef struct OCURI {
|
|
char* uri; /* as passed buy the caller */
|
|
char* params; /* all params */
|
|
char** paramlist; /*!<null terminated list */
|
|
char* constraint; /*!< projection+selection */
|
|
char* projection; /*!< without leading '?'*/
|
|
char* selection; /*!< with leading '&'*/
|
|
char* strings; /* first char of strings is always '\0' */
|
|
/* Following all point into the strings field */
|
|
char* protocol;
|
|
char* userpwd; /* from user:password@ */
|
|
char* host; /*!< host*/
|
|
char* port; /*!< host */
|
|
char* file; /*!< file */
|
|
} OCURI;
|
|
|
|
extern int ocuriparse(const char* s, OCURI** ocuri);
|
|
extern void ocurifree(OCURI* ocuri);
|
|
|
|
/* Replace the constraints */
|
|
extern void ocurisetconstraints(OCURI*,const char* constraints);
|
|
|
|
/* Construct a complete OC URI; caller frees returned string */
|
|
|
|
/* Define flags to control what is included */
|
|
#define OCURICONSTRAINTS 1
|
|
#define OCURIUSERPWD 2
|
|
#define OCURIPREFIXPARAMS 4
|
|
#define OCURISUFFIXPARAMS 8
|
|
#define OCURIPARAMS OCURIPREFIXPARAMS
|
|
#define OCURIENCODE 16 /* If output should be encoded */
|
|
#define OCURISTD (OCURICONSTRAINTS|OCURIUSERPWD)
|
|
#define OCURIALL (0xFFFF)
|
|
|
|
extern char* ocuribuild(OCURI*,const char* prefix, const char* suffix, int flags);
|
|
|
|
|
|
/* Param Management */
|
|
extern int ocuridecodeparams(OCURI* ocuri);
|
|
extern int ocurisetparams(OCURI* ocuri,const char*);
|
|
|
|
/*! 0 result => entry not found; 1=>found; result holds value (may be null).
|
|
In any case, the result is imutable and should not be free'd.
|
|
*/
|
|
extern int ocurilookup(OCURI*, const char* param, const char** result);
|
|
|
|
extern char* ocuriencode(char* s, char* allowable);
|
|
extern char* ocuridecode(char* s);
|
|
extern char* ocuridecodeonly(char* s, char*);
|
|
|
|
#endif /*OCURI_H*/
|