/// <summary>Insert this tree and obtain its ObjectId.</summary> /// <remarks>Insert this tree and obtain its ObjectId.</remarks> /// <param name="ins">the inserter to store the tree.</param> /// <returns>computed ObjectId of the tree</returns> /// <exception cref="System.IO.IOException">the tree could not be stored.</exception> public virtual ObjectId InsertTo(ObjectInserter ins) { if (buf != null) { return(ins.Insert(Constants.OBJ_TREE, buf, 0, ptr)); } long len = overflowBuffer.Length(); return(ins.Insert(Constants.OBJ_TREE, len, overflowBuffer.OpenInputStream())); }
// We should drop the current source entry from the window, // it is somehow invalid for us to work with. private bool IsBetterDelta(DeltaWindowEntry src, TemporaryBuffer.Heap resDelta) { if (bestDelta == null) { return(true); } // If both delta sequences are the same length, use the one // that has a shorter delta chain since it would be faster // to access during reads. // if (resDelta.Length() == bestDelta.Length()) { return(src.Depth() < window[bestSlot].Depth()); } return(resDelta.Length() < bestDelta.Length()); }
/// <exception cref="System.IO.IOException"></exception> internal virtual void SendRequest() { // Try to compress the content, but only if that is smaller. TemporaryBuffer buf = new TemporaryBuffer.Heap(this._enclosing.http.postBuffer); try { GZIPOutputStream gzip = new GZIPOutputStream(buf); [email protected](gzip, null); gzip.Close(); if ([email protected]() < buf.Length()) { buf = this.@out; } } catch (IOException) { // Most likely caused by overflowing the buffer, meaning // its larger if it were compressed. Don't compress. buf = this.@out; } this.OpenStream(); if (buf != this.@out) { this.conn.SetRequestProperty(HttpSupport.HDR_CONTENT_ENCODING, HttpSupport.ENCODING_GZIP ); } this.conn.SetFixedLengthStreamingMode((int)buf.Length()); OutputStream httpOut = this.conn.GetOutputStream(); try { buf.WriteTo(httpOut, null); } finally { httpOut.Close(); } }
/// <exception cref="System.IO.IOException"></exception> internal virtual void Execute() { [email protected](); if (this.conn == null) { // Output hasn't started yet, because everything fit into // our request buffer. Send with a Content-Length header. // if ([email protected]() == 0) { throw new TransportException(this._enclosing.uri, JGitText.Get().startingReadStageWithoutWrittenRequestDataPendingIsNotSupported ); } // Try to compress the content, but only if that is smaller. TemporaryBuffer buf = new TemporaryBuffer.Heap(this._enclosing.http.postBuffer); try { GZIPOutputStream gzip = new GZIPOutputStream(buf); [email protected](gzip, null); gzip.Close(); if ([email protected]() < buf.Length()) { buf = this.@out; } } catch (IOException) { // Most likely caused by overflowing the buffer, meaning // its larger if it were compressed. Don't compress. buf = this.@out; } this.OpenStream(); if (buf != this.@out) { this.conn.SetRequestProperty(HttpSupport.HDR_CONTENT_ENCODING, HttpSupport.ENCODING_GZIP ); } this.conn.SetFixedLengthStreamingMode((int)buf.Length()); OutputStream httpOut = this.conn.GetOutputStream(); try { buf.WriteTo(httpOut, null); } finally { httpOut.Close(); } } [email protected](); int status = HttpSupport.Response(this.conn); if (status != HttpURLConnection.HTTP_OK) { throw new TransportException(this._enclosing.uri, status + " " + this.conn.GetResponseMessage ()); } //$NON-NLS-1$ string contentType = this.conn.GetContentType(); if (!this.responseType.Equals(contentType)) { this.conn.GetInputStream().Close(); throw this._enclosing.WrongContentType(this.responseType, contentType); } [email protected](this._enclosing.OpenInputStream(this.conn)); [email protected](this.execute); this.conn = null; }