private static void sendInfoRefsError(HttpServletRequest req, HttpServletResponse res, String textForGit) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(128); PacketLineOut pck = new PacketLineOut(buf); String svc = req.getParameter("service"); pck.writeString("# service=" + svc + "\n"); pck.end(); pck.writeString("ERR " + textForGit); send(req, res, infoRefsResultType(svc), buf.toByteArray()); }
/** * Get the response Content-Type a client expects for the request. * <p> * This method should only be invoked if * {@link #isGitClient(HttpServletRequest)} is true. * * @param req * current request. * @return the Content-Type the client expects. * @throws IllegalArgumentException * the request is not a Git client request. See * {@link #isGitClient(HttpServletRequest)}. */ public static String getResponseContentType(HttpServletRequest req) { if (isInfoRefs(req)) return infoRefsResultType(req.getParameter("service")); else if (isUploadPack(req)) return UPLOAD_PACK_RESULT_TYPE; else if (isReceivePack(req)) return RECEIVE_PACK_RESULT_TYPE; else throw new IllegalArgumentException(); }
private static void sendInfoRefsError(HttpServletRequest req, HttpServletResponse res, String textForGit) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(128); PacketLineOut pck = new PacketLineOut(buf); String svc = req.getParameter("service"); pck.writeString("# service=" + svc + "\n"); pck.end(); pck.writeString("ERR " + textForGit); send(req, res, infoRefsResultType(svc), buf.toByteArray()); }
/** * Get the response Content-Type a client expects for the request. * <p> * This method should only be invoked if * {@link #isGitClient(HttpServletRequest)} is true. * * @param req * current request. * @return the Content-Type the client expects. * @throws IllegalArgumentException * the request is not a Git client request. See * {@link #isGitClient(HttpServletRequest)}. */ public static String getResponseContentType(HttpServletRequest req) { if (isInfoRefs(req)) return infoRefsResultType(req.getParameter("service")); else if (isUploadPack(req)) return UPLOAD_PACK_RESULT_TYPE; else if (isReceivePack(req)) return RECEIVE_PACK_RESULT_TYPE; else throw new IllegalArgumentException(); }
private void service(ServletRequest request, ServletResponse response) throws IOException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; final SmartOutputStream buf = new SmartOutputStream(req, res, true); try { res.setContentType(infoRefsResultType(svc)); final PacketLineOut out = new PacketLineOut(buf); out.writeString("# service=" + svc + "\n"); out.end(); advertise(req, new PacketLineOutRefAdvertiser(out)); buf.close(); } catch (ServiceNotAuthorizedException e) { res.sendError(SC_UNAUTHORIZED); } catch (ServiceNotEnabledException e) { sendError(req, res, SC_FORBIDDEN); } catch (ServiceMayNotContinueException e) { if (e.isOutput()) buf.close(); else sendError(req, res, SC_FORBIDDEN, e.getMessage()); } }
private void service(ServletRequest request, ServletResponse response) throws IOException { final HttpServletRequest req = (HttpServletRequest) request; final HttpServletResponse res = (HttpServletResponse) response; final SmartOutputStream buf = new SmartOutputStream(req, res, true); try { res.setContentType(infoRefsResultType(svc)); final PacketLineOut out = new PacketLineOut(buf); out.writeString("# service=" + svc + "\n"); out.end(); advertise(req, new PacketLineOutRefAdvertiser(out)); buf.close(); } catch (ServiceNotAuthorizedException e) { res.sendError(SC_UNAUTHORIZED, e.getMessage()); } catch (ServiceNotEnabledException e) { sendError(req, res, SC_FORBIDDEN, e.getMessage()); } catch (ServiceMayNotContinueException e) { if (e.isOutput()) buf.close(); else sendError(req, res, e.getStatusCode(), e.getMessage()); } }