[c-sharp] view plaincopy
- protected void service(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
- String method = req.getMethod();
- if(method.equals("GET"))
- {
- long lastModified = getLastModified(req);
- if(lastModified == -1L)
- {
- doGet(req, resp);
- } else
- {
- long ifModifiedSince = req.getDateHeader("If-Modified-Since");
- if(ifModifiedSince < (lastModified / 1000L) * 1000L)
- {
- maybeSetLastModified(resp, lastModified);
- doGet(req, resp);
- } else
- {
- resp.setStatus(304);
- }
- }
- } else
- if(method.equals("HEAD"))
- {
- long lastModified = getLastModified(req);
- maybeSetLastModified(resp, lastModified);
- doHead(req, resp);
- } else
- if(method.equals("POST"))
- doPost(req, resp);
- else
- if(method.equals("PUT"))
- doPut(req, resp);
- else
- if(method.equals("DELETE"))
- doDelete(req, resp);
- else
- if(method.equals("OPTIONS"))
- doOptions(req, resp);
- else
- if(method.equals("TRACE"))
- {
- doTrace(req, resp);
- } else
- {
- String errMsg = lStrings.getString("http.method_not_implemented");
- Object errArgs[] = new Object[1];
- errArgs[0] = method;
- errMsg = MessageFormat.format(errMsg, errArgs);
- resp.sendError(501, errMsg);
- }
- }
时间: 2024-10-12 12:22:34