mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-09 08:11:38 +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"
83 lines
1.5 KiB
C
83 lines
1.5 KiB
C
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
|
See the COPYRIGHT file for more information. */
|
|
|
|
#include "config.h"
|
|
#ifdef HAVE_STDARG_H
|
|
#include <stdarg.h>
|
|
#endif
|
|
#include "ocinternal.h"
|
|
#include "ocdebug.h"
|
|
|
|
int ocdebug;
|
|
|
|
#ifdef OCCATCHERROR
|
|
/* Place breakpoint here to catch errors close to where they occur*/
|
|
OCerror
|
|
ocbreakpoint(OCerror err) {return err;}
|
|
|
|
OCerror
|
|
occatch(OCerror err)
|
|
{
|
|
if(err == 0) return err;
|
|
return ocbreakpoint(err);
|
|
}
|
|
#endif
|
|
|
|
int
|
|
xxdrerror(void)
|
|
{
|
|
oclog(OCLOGERR,"xdr failure");
|
|
return OCCATCH(OC_EDATADDS);
|
|
}
|
|
|
|
|
|
void*
|
|
occalloc(size_t size, size_t nelems)
|
|
{
|
|
return ocmalloc(size*nelems);
|
|
}
|
|
|
|
void*
|
|
ocmalloc(size_t size)
|
|
{
|
|
void* memory = calloc(size,1); /* use calloc to zero memory*/
|
|
if(memory == NULL) oclog(OCLOGERR,"ocmalloc: out of memory");
|
|
return memory;
|
|
}
|
|
|
|
void
|
|
ocfree(void* mem)
|
|
{
|
|
if(mem != NULL) free(mem);
|
|
}
|
|
|
|
int
|
|
ocpanic(const char* fmt, ...)
|
|
{
|
|
va_list args;
|
|
if(fmt != NULL) {
|
|
va_start(args, fmt);
|
|
vfprintf(stderr, fmt, args);
|
|
fprintf(stderr, "\n" );
|
|
va_end( args );
|
|
} else {
|
|
fprintf(stderr, "panic" );
|
|
}
|
|
fprintf(stderr, "\n" );
|
|
fflush(stderr);
|
|
return 0;
|
|
}
|
|
|
|
CURLcode
|
|
ocreportcurlerror(OCstate* state, CURLcode cstat)
|
|
{
|
|
if(cstat != CURLE_OK) {
|
|
fprintf(stderr,"CURL Error: %s",curl_easy_strerror(cstat));
|
|
if(state != NULL)
|
|
fprintf(stderr," ; %s",state->error.curlerrorbuf);
|
|
fprintf(stderr,"\n");
|
|
}
|
|
fflush(stderr);
|
|
return cstat;
|
|
}
|