From: Robert Tansley <roberttansley@go...>  20060927 18:41:30

I didn't do it that way because it would be far messier. The DSpace Context isn't created when service() is called, so getLastModified(req) would need to create a Context and instantiate the item to figure out the last modified date. Then you'd have to either stuff that in a request attribute for the later doGet() somehow or do everything twice. On 27/09/06, Mark Diggory <mdiggory@...> wrote: > I see you just did the commit so this is probably just informational > now. > > Note, there already is available functionality in the Servlet API you > can override to implement such a usecase, it would be more > extensible a strategy than you've accomplished by inlining the logic > for determining the lastModified timestamp into the dsGet method > > You can generalize the case by just overriding "getLastModified" in > the DSpaceServlet and/or the actual servlet (HandleServlet etc) for > more customized behavior. > > "maybeSetLastModified" can be overridden to return the new last > Modified header to the browser/client as well. > > Mark > > See the following HttpServlet code: > > http://www.docjar.com/html/api/javax/servlet/http/HttpServlet.java.html > > > > protected void service(HttpServletRequest req, > > HttpServletResponse resp) > > 680 throws ServletException, IOException > > 681 { > > 682 String method = req.getMethod(); > > 683 > > 684 if (method.equals(METHOD_GET)) { > > 685 long lastModified = getLastModified(req); > > 686 if (lastModified == 1) { > > 687 // servlet doesn't support ifmodifiedsince, no reason > > 688 // to go through further expensive logic > > 689 doGet(req, resp); > > 690 } else { > > 691 long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE); > > 692 if (ifModifiedSince < (lastModified / 1000 * 1000)) { > > 693 // If the servlet mod time is later, call doGet() > > 694 // Round down to the nearest second for a > > proper compare > > 695 // A ifModifiedSince of 1 will always be less > > 696 maybeSetLastModified(resp, lastModified); > > 697 doGet(req, resp); > > 698 } else { > > 699 resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); > > 700 } > > 701 } > > 702 > > 703 } else if (method.equals(METHOD_HEAD)) { > > 704 long lastModified = getLastModified(req); > > 705 maybeSetLastModified(resp, lastModified); > > 706 doHead(req, resp); > > 707 > > 708 } else if (method.equals(METHOD_POST)) { > > 709 doPost(req, resp); > > 710 > > 711 } else if (method.equals(METHOD_PUT)) { > > 712 doPut(req, resp); > > 713 > > 714 } else if (method.equals(METHOD_DELETE)) { > > 715 doDelete(req, resp); > > 716 > > 717 } else if (method.equals(METHOD_OPTIONS)) { > > 718 doOptions(req,resp); > > 719 > > 720 } else if (method.equals(METHOD_TRACE)) { > > 721 doTrace(req,resp); > > 722 > > 723 } else { > > 724 // > > 725 // Note that this means NO servlet supports whatever > > 726 // method was requested, anywhere on this server. > > 727 // > > 728 > > 729 String errMsg = lStrings.getString > > ("http.method_not_implemented"); > > 730 Object[] errArgs = new Object[1]; > > 731 errArgs[0] = method; > > 732 errMsg = MessageFormat.format(errMsg, errArgs); > > 733 > > 734 resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, > > errMsg); > > 735 } > > 736 } > > > On Sep 27, 2006, at 9:34 AM, Robert Tansley wrote: > > > Good point, I can find out about the HEAD thing for GoogleBot, though > > sysadmins may be able to tell by looking through their logs. > > > > However I'm not sure implementing it would make much difference, since > > if the IfModifiedSince header prompts a 304 response, a HEAD is no > > cheaper than a GET to service. And if it doesn't the bot is just > > going to have to issue a further GET. > > > > What might be useful is an index of last modified dates, meaning you > > can respond 304 without having to instantiate the corresponding Item > > object, but that would be a bigger change (i.e. one for 1.5). > > > > On 26/09/06, Mark Diggory <mdiggory@...> wrote: > >> Do we handle this sort of thing on HEAD requests as well? Are there > >> proxies/crawlers which use HEAD requests to get this sort of response > >> detail? Some suggest Googlebot is using it. > >> > >> http://www.seroundtable.com/archives/004079.html > >> http://forums.seochat.com/searchenginespiders27/spidersusing > >> head > >> requests45861.html > >> > >> Mark > >> > >> > >> On Sep 26, 2006, at 5:23 PM, Robert Tansley wrote: > >> > >>> I just posted a small patch for Ifmodifiedsince HTTP request > >>> header support: > >>> > >>> https://sourceforge.net/tracker/index.php? > >>> func=detail&aid=1565975&group_id=19984&atid=319984 > >>> > >>> which should help folks whose servers are straining under search > >>> enginge web crawler load. It's more or less a bug fix, so sould > >>> be OK > >>> for 1.4.1  if there are no objections, I'll commit it tomorrow, > >>> but > >>> would appreciate it if someone would give it a quick look over to > >>> make > >>> sure it looks reasonable. > >>> > >>>  > >>>  > >>>  > >>> Take Surveys. Earn Cash. Influence the Future of IT > >>> Join SourceForge.net's Techsay panel and you'll get the chance to > >>> share your > >>> opinions on IT & business topics through brief surveys  and earn > >>> cash > >>> http://www.techsay.com/default.php? > >>> page=join.php&p=sourceforge&CID=DEVDEV > >>> _______________________________________________ > >>> Dspacedevel mailing list > >>> Dspacedevel@... > >>> https://lists.sourceforge.net/lists/listinfo/dspacedevel > >> > >> Mark R. Diggory > >> ~~~~~~~~~~~~~ > >> DSpace Systems Manager > >> MIT Libraries, Systems and Technology Services > >> Massachusetts Institute of Technology > >> > >> > >> > > > >  > >  > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to > > share your > > opinions on IT & business topics through brief surveys  and earn > > cash > > http://www.techsay.com/default.php? > > page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Dspacedevel mailing list > > Dspacedevel@... > > https://lists.sourceforge.net/lists/listinfo/dspacedevel > > Mark R. Diggory > ~~~~~~~~~~~~~ > DSpace Systems Manager > MIT Libraries, Systems and Technology Services > Massachusetts Institute of Technology > > > 