Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 156133 Details for
Bug 235355
mod_revocator should use If-Modified-Since
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to include If-Modified-Since and handle that response
diff.out (text/plain), 8.76 KB, created by
Rob Crittenden
on 2007-06-04 21:08:22 UTC
(
hide
)
Description:
Patch to include If-Modified-Since and handle that response
Filename:
MIME Type:
Creator:
Rob Crittenden
Created:
2007-06-04 21:08:22 UTC
Size:
8.76 KB
patch
obsolete
>Index: client.cpp >=================================================================== >RCS file: /cvs/dirsec/mod_revocator/client.cpp,v >retrieving revision 1.2 >diff -u -r1.2 client.cpp >--- client.cpp 4 Aug 2006 18:53:09 -0000 1.2 >+++ client.cpp 4 Jun 2007 21:04:34 -0000 >@@ -58,7 +58,11 @@ > { 20, "Unable to connect to remote host" }, > { 21, "Unable to write data to remote server" }, > { 22, "Unable to read data from remote server" }, >- { 23, "Out of memory while reading data" } >+ { 23, "Out of memory while reading data" }, >+ { 24, "Pipe failed" }, >+ { 25, "Fork failed" }, >+ { 26, "Exec failed" }, >+ { 27, "HTTP 304 Not Modified returned. The CRL hasn't changed since the last retrieval." } > }; > > /* Given a URL, determine the type and fetch the appropriate contents and >@@ -73,7 +77,7 @@ > * > * See the ldap-client.cpp and http-client.cpp for specific URL syntax. > */ >-PR_IMPLEMENT(void *)fetch_url(const char * url, int timeout, int * len, RevStatus& status) >+PR_IMPLEMENT(void *)fetch_url(const char * url, int timeout, PRTime lastfetchtime, int * len, RevStatus& status) > { > int errnum = -1; > void * data = NULL; >@@ -86,14 +90,16 @@ > if (!PL_strncasecmp(url, "ldap", 4)) > data = ldap_client(url, timeout, len, &errnum); > else if (!PL_strncasecmp(url, "http", 4)) >- data = http_client(url, timeout, len, &errnum); >+ data = http_client(url, timeout, lastfetchtime, len, &errnum); > else if (!PL_strncasecmp(url, "exec", 4)) > data = exec_client(url, timeout, len, &errnum); > else > errnum = CL_URL_UNKNOWN; > } > >- if (errnum != -1) { >+ if (errnum == CL_NOUPDATE_AVAILABLE) { >+ status.setError(REV_ERROR_NOUPDATE_AVAILABLE, client_errors[errnum].errorString); >+ } else if (errnum != -1) { > status.setError(REV_ERROR_INVALID_URL_TYPE, client_errors[errnum].errorString); > } > >Index: client.h >=================================================================== >RCS file: /cvs/dirsec/mod_revocator/client.h,v >retrieving revision 1.2 >diff -u -r1.2 client.h >--- client.h 4 Aug 2006 18:53:09 -0000 1.2 >+++ client.h 4 Jun 2007 21:04:35 -0000 >@@ -26,11 +26,11 @@ > #include <nspr.h> > #include "revocation.h" > >-PR_EXTERN(void *)fetch_url(const char * url, int timeout, int * len, RevStatus& status); >+PR_EXTERN(void *)fetch_url(const char * url, int timeout, PRTime lastfetchtime, int * len, RevStatus& status); > > PR_EXTERN(void)free_url(void* urldata); > >-PR_EXTERN(void *)http_client(const char *url, int timeout, int * len, int * errnum); >+PR_EXTERN(void *)http_client(const char *url, int timeout, PRTime lastfetchtime, int * len, int * errnum); > > int parse_url(const char *url, char **username, char **password, char **protocol , char **host, int *port, char **uri); > >Index: client_err.h >=================================================================== >RCS file: /cvs/dirsec/mod_revocator/client_err.h,v >retrieving revision 1.2 >diff -u -r1.2 client_err.h >--- client_err.h 4 Aug 2006 18:53:09 -0000 1.2 >+++ client_err.h 4 Jun 2007 21:04:35 -0000 >@@ -53,6 +53,7 @@ > #define CL_HTTP_WRITE_FAILED 21 > #define CL_HTTP_READ_FAILED 22 > #define CL_OUT_OF_MEMORY 23 >+#define CL_NOUPDATE_AVAILABLE 27 > > /* EXEC client errors */ > #define CL_PIPE_FAILED 24 >Index: crlmanager.cpp >=================================================================== >RCS file: /cvs/dirsec/mod_revocator/crlmanager.cpp,v >retrieving revision 1.2 >diff -u -r1.2 crlmanager.cpp >--- crlmanager.cpp 4 Aug 2006 18:53:09 -0000 1.2 >+++ crlmanager.cpp 4 Jun 2007 21:04:35 -0000 >@@ -55,7 +55,22 @@ > RevStatus mystatus; > PRInt32 len = 0 ; > output = NULL; >- void* data = fetch_url(inurl, timeout, &len, mystatus); >+ void* data = fetch_url(inurl, timeout, lastfetchtime, &len, mystatus); >+ >+ /* We have a special case. If we have an HTTP request and the server >+ * response was 304 Not Modified we want to go ahead and continue as >+ * if the request was successful. A CRL may be very large so this is >+ * a good thing, we just have to jump through some hoops to achieve >+ * it. First we log the fact that we tried and got a 304, then reset >+ * things so in GetCRL() and update() we can detect this case. >+ */ >+ if (mystatus.getError() == REV_ERROR_NOUPDATE_AVAILABLE) { >+ reportError(mystatus); /* Report the error while we have it */ >+ mystatus.clearError(); >+ output = SECITEM_AllocItem(NULL, NULL, 1); >+ output->len = 0; >+ return mystatus; >+ } > if (!mystatus.hasFailed() && (!data || !len)) > { > // the download did not fail, but we didn't get any data ... >@@ -327,6 +342,10 @@ > } > PR_ASSERT(derCRL); > >+ if (derCRL->len == 0) { /* no data retuned from server, this is ok */ >+ return mystatus; >+ } >+ > // now check the CRL > if ((mystatus = ProcessCRL(*derCRL, decodedCRL, now)).hasFailed()) > { >@@ -408,6 +427,12 @@ > { > reportError(mystatus); > } >+ if (derCrl->len == 0) { /* This is ok, see DownloadCRL */ >+ lastfetchtime = now; >+ SECITEM_FreeItem(derCrl, PR_TRUE); >+ derCrl = NULL; >+ return mystatus; >+ } > > if (!mystatus.hasFailed()) > { >Index: http-client.cpp >=================================================================== >RCS file: /cvs/dirsec/mod_revocator/http-client.cpp,v >retrieving revision 1.3 >diff -u -r1.3 http-client.cpp >--- http-client.cpp 16 Oct 2006 18:16:35 -0000 1.3 >+++ http-client.cpp 4 Jun 2007 21:04:36 -0000 >@@ -76,7 +76,8 @@ > * > * The timeout is in seconds. > */ >-PR_IMPLEMENT(void *)http_client(const char *url, int timeout, int * len, int * errnum) >+PR_IMPLEMENT(void *)http_client(const char *url, int timeout, >+ PRTime lastfetchtime, int * len, int * errnum) > { > char * protocol = 0; > char * host = 0; >@@ -96,7 +97,9 @@ > PRInt32 cl = 0; > int ssl = 0; > unsigned int lenp; >- >+ PRExplodedTime printableTime; >+ char ifmodified[256]; >+ > uri_unescape_strict((char *)url, 0); // decode the url > > if (!parse_url(url, &username, &password, &protocol, &host, &port, &uri)) { >@@ -140,18 +143,26 @@ > strncpy(hostline, host, BIG_LINE); > else > PR_snprintf(hostline, sizeof(hostline), "%s:%d", host, port); >+ >+ memset(ifmodified, 0, 256); >+ if (lastfetchtime > 0) { >+ PR_ExplodeTime(lastfetchtime, PR_GMTParameters, &printableTime); >+ PR_FormatTime(ifmodified, 256, "%a, %d %b %Y %H:%M:%S GMT", &printableTime); >+ } > > /* Construct the HTTP request */ > PR_snprintf(buffer, sizeof(buffer), >- "GET %s HTTP/1.0\r\n" >+ "GET %s HTTP/1.1\r\n" > "%s%s%s" > "Host: %s\r\n" > "User-Agent: %s/%s\r\n" >+ "%s%s%s" > "Connection: close\r\n\r\n", > uri, > authdata ? "Authorization: Basic " : "", authdata ? authdata: "", authdata ? "\r\n" : "", > hostline, >- PRODUCT_BRAND_NAME, PRODUCT_VERSION_ID); >+ PRODUCT_BRAND_NAME, PRODUCT_VERSION_ID, >+ ifmodified[0] ? "If-Modified-Since: " : "", ifmodified[0] ? ifmodified : "", ifmodified[0] ? "\r\n" : ""); > > if (authdata) > free(authdata); >@@ -165,6 +176,11 @@ > > /* a content-length of -1 means read until there is no more to read */ > cl = get_content_length(sock, timeout); >+ if (cl == -2) { >+ cl = 0; /* so we don't end up with a bogus len in done: */ >+ *errnum = CL_NOUPDATE_AVAILABLE; >+ goto done; >+ } > if (cl != 0) { > > totalread = 0; >@@ -397,18 +413,18 @@ > if ((y == -1) && (nh > 0)) { > return 0; /* name without value */ > } >- if (y == -1) { /* HTTP status message */ >- x = 0; >- y = -1; >- ++nh; >- break; >- } > while (t[y] && isspace(t[y])) > ++y; > > header = strtok(t, ":"); >- if (!PL_strcasecmp("content-length", header)) >- length = atoi(&t[y]); >+ if (header) { >+ char *s = t; >+ s += 9; /* skip 'http/1.x ' */ >+ if (s && !PL_strncmp(s, "304", 3)) >+ length = -2; >+ else if (!PL_strcasecmp("content-length", header)) >+ length = atoi(&t[y]); >+ } > > x = 0; > y = -1; >Index: reverror.h >=================================================================== >RCS file: /cvs/dirsec/mod_revocator/reverror.h,v >retrieving revision 1.2 >diff -u -r1.2 reverror.h >--- reverror.h 4 Aug 2006 18:53:09 -0000 1.2 >+++ reverror.h 4 Jun 2007 21:04:36 -0000 >@@ -53,6 +53,7 @@ > const PRInt32 REV_ERROR_BAD_ISSUER_USAGE = 1013; > const PRInt32 REV_ERROR_MISSING_CRL_DATA = 1014; > const PRInt32 REV_ERROR_BAD_ISSUER_TRUST = 1015; >+const PRInt32 REV_ERROR_NOUPDATE_AVAILABLE = 1016; > > #endif >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 235355
:
156133
|
156225