List of usage examples for org.eclipse.jgit.transport PacketLineIn END
String END
To view the source code for org.eclipse.jgit.transport PacketLineIn END.
Click Source Link
From source file:com.google.gerrit.sshd.commands.UploadArchive.java
License:Apache License
/** * Read and parse arguments from input stream. * This method gets the arguments from input stream, in Pkt-line format, * then parses them to fill the options object. *///from ww w.j a va 2 s . c o m protected void readArguments() throws IOException, Failure { String argCmd = "argument "; List<String> args = Lists.newArrayList(); // Read arguments in Pkt-Line format PacketLineIn packetIn = new PacketLineIn(in); for (;;) { String s = packetIn.readString(); if (s == PacketLineIn.END) { break; } if (!s.startsWith(argCmd)) { throw new Failure(1, "fatal: 'argument' token or flush expected"); } String[] parts = s.substring(argCmd.length()).split("=", 2); for (String p : parts) { args.add(p); } } try { // Parse them into the 'options' field CmdLineParser parser = new CmdLineParser(options); parser.parseArgument(args); if (options.path == null || Arrays.asList(".").equals(options.path)) { options.path = Collections.emptyList(); } } catch (CmdLineException e) { throw new Failure(2, "fatal: unable to parse arguments, " + e); } }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.FixedTransportHttp.java
License:Eclipse Distribution License
private void readSmartHeaders(final InputStream in, final String service) throws IOException { // A smart reply will have a '#' after the first 4 bytes, but // a dumb reply cannot contain a '#' until after byte 41. Do a // quick check to make sure its a smart reply before we parse // as a pkt-line stream. ///* ww w . j av a2s . c om*/ final byte[] magic = new byte[5]; IO.readFully(in, magic, 0, magic.length); if (magic[4] != '#') { throw new TransportException(uri, MessageFormat.format(JGitText.get().expectedPktLineWithService, RawParseUtils.decode(magic))); } final PacketLineIn pckIn = new PacketLineIn(new UnionInputStream(new ByteArrayInputStream(magic), in)); final String exp = "# service=" + service; //$NON-NLS-1$ final String act = pckIn.readString(); if (!exp.equals(act)) { throw new TransportException(uri, MessageFormat.format(JGitText.get().expectedGot, exp, act)); } while (pckIn.readString() != PacketLineIn.END) { // for now, ignore the remaining header lines } }