Beispiel #1
0
        /// <exception cref="System.IO.IOException"></exception>
        internal virtual void Service(string name, PacketLineOut pckOut)
        {
            StringBuilder cmd = new StringBuilder();

            cmd.Append(name);
            cmd.Append(' ');
            cmd.Append(uri.GetPath());
            cmd.Append('\0');
            cmd.Append("host=");
            cmd.Append(uri.GetHost());
            if (uri.GetPort() > 0 && uri.GetPort() != GIT_PORT)
            {
                cmd.Append(":");
                cmd.Append(uri.GetPort());
            }
            cmd.Append('\0');
            pckOut.WriteString(cmd.ToString());
            pckOut.Flush();
        }
        public virtual void TestWritePacket3()
        {
            int buflen = SideBandOutputStream.MAX_BUF - 5;

            byte[] buf = new byte[buflen];
            for (int i = 0; i < buf.Length; i++)
            {
                buf[i] = unchecked ((byte)i);
            }
            @out.WritePacket(buf);
            @out.Flush();
            byte[] act    = rawOut.ToByteArray();
            string explen = Sharpen.Extensions.ToString(buf.Length + 4, 16);

            NUnit.Framework.Assert.AreEqual(4 + buf.Length, act.Length);
            NUnit.Framework.Assert.AreEqual(Sharpen.Runtime.GetStringForBytes(act, 0, 4, "UTF-8"
                                                                              ), explen);
            for (int i_1 = 0, j = 4; i_1 < buf.Length; i_1++, j++)
            {
                NUnit.Framework.Assert.AreEqual(buf[i_1], act[j]);
            }
        }
Beispiel #3
0
        /// <exception cref="System.IO.IOException"></exception>
        private bool Negotiate()
        {
            okToGiveUp = false;
            ObjectId         last    = ObjectId.ZeroId;
            IList <ObjectId> peerHas = new AList <ObjectId>(64);

            for (; ;)
            {
                string line;
                try
                {
                    line = pckIn.ReadString();
                }
                catch (EOFException eof)
                {
                    throw;
                }
                if (line == PacketLineIn.END)
                {
                    last = ProcessHaveLines(peerHas, last);
                    if (commonBase.IsEmpty() || multiAck != BasePackFetchConnection.MultiAck.OFF)
                    {
                        pckOut.WriteString("NAK\n");
                    }
                    if (!biDirectionalPipe)
                    {
                        return(false);
                    }
                    pckOut.Flush();
                }
                else
                {
                    if (line.StartsWith("have ") && line.Length == 45)
                    {
                        peerHas.AddItem(ObjectId.FromString(Sharpen.Runtime.Substring(line, 5)));
                    }
                    else
                    {
                        if (line.Equals("done"))
                        {
                            last = ProcessHaveLines(peerHas, last);
                            if (commonBase.IsEmpty())
                            {
                                pckOut.WriteString("NAK\n");
                            }
                            else
                            {
                                if (multiAck != BasePackFetchConnection.MultiAck.OFF)
                                {
                                    pckOut.WriteString("ACK " + last.Name + "\n");
                                }
                            }
                            return(true);
                        }
                        else
                        {
                            throw new PackProtocolException(MessageFormat.Format(JGitText.Get().expectedGot,
                                                                                 "have", line));
                        }
                    }
                }
            }
        }
		/// <exception cref="System.IO.IOException"></exception>
		internal virtual void Service(string name, PacketLineOut pckOut)
		{
			StringBuilder cmd = new StringBuilder();
			cmd.Append(name);
			cmd.Append(' ');
			cmd.Append(uri.GetPath());
			cmd.Append('\0');
			cmd.Append("host=");
			cmd.Append(uri.GetHost());
			if (uri.GetPort() > 0 && uri.GetPort() != GIT_PORT)
			{
				cmd.Append(":");
				cmd.Append(uri.GetPort());
			}
			cmd.Append('\0');
			pckOut.WriteString(cmd.ToString());
			pckOut.Flush();
		}