This file is indexed.

/usr/lib/ruby/1.8/net_fix.rb is in libright-http-connection-ruby1.8 1.2.4-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#
# Copyright (c) 2008 RightScale Inc
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
#

# Net::HTTP and Net::HTTPGenericRequest fixes to support 100-continue on 
# POST and PUT. The request must have 'expect' field set to '100-continue'.


module Net
  
  class BufferedIO #:nodoc:
    # Monkey-patch Net::BufferedIO to read > 1024 bytes from the socket at a time

    # Default size (in bytes) of the max read from a socket into the user space read buffers for socket IO
    DEFAULT_SOCKET_READ_SIZE = 16*1024

    @@socket_read_size = DEFAULT_SOCKET_READ_SIZE

    def self.socket_read_size=(readsize)
      if(readsize <= 0)
        return
      end
      @@socket_read_size = readsize
    end

    def self.socket_read_size?()
      @@socket_read_size
    end

    def rbuf_fill
      timeout(@read_timeout) {
        @rbuf << @io.sysread(@@socket_read_size)
      }
    end
  end


  #-- Net::HTTPGenericRequest --

  class HTTPGenericRequest
    # Monkey-patch Net::HTTPGenericRequest to read > 1024 bytes from the local data
    # source at a time (used in streaming PUTs)

    # Default size (in bytes) of the max read from a local source (File, String,
    # etc.) to the user space write buffers for socket IO.
    DEFAULT_LOCAL_READ_SIZE = 16*1024

    @@local_read_size = DEFAULT_LOCAL_READ_SIZE

    def self.local_read_size=(readsize)
      if(readsize <= 0)
        return
      end
      @@local_read_size = readsize
    end

    def self.local_read_size?()
      @@local_read_size
    end

    def exec(sock, ver, path, send_only=nil)   #:nodoc: internal use only
      if @body
        send_request_with_body sock, ver, path, @body, send_only
      elsif @body_stream
        send_request_with_body_stream sock, ver, path, @body_stream, send_only
      else
        write_header(sock, ver, path)
      end
    end

    private

    def send_request_with_body(sock, ver, path, body, send_only=nil)
      self.content_length = body.length
      delete 'Transfer-Encoding'
      supply_default_content_type
      write_header(sock, ver, path) unless send_only == :body
      sock.write(body)              unless send_only == :header
    end

    def send_request_with_body_stream(sock, ver, path, f, send_only=nil)
      unless content_length() or chunked?
        raise ArgumentError,
            "Content-Length not given and Transfer-Encoding is not `chunked'"
      end
      supply_default_content_type
      write_header(sock, ver, path) unless send_only == :body
      unless send_only == :header
        if chunked?
          while s = f.read(@@local_read_size)
            sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
          end
          sock.write "0\r\n\r\n"
        else
          while s = f.read(@@local_read_size)
            sock.write s
          end
        end
      end
    end    
  end


  #-- Net::HTTP --
  
  class HTTP
    def request(req, body = nil, &block)  # :yield: +response+
      unless started?
        start {
          req['connection'] ||= 'close'
          return request(req, body, &block)
        }
      end
      if proxy_user()
        unless use_ssl?
          req.proxy_basic_auth proxy_user(), proxy_pass()
        end
      end
      # set body
      req.set_body_internal body
      begin_transport req
        # if we expect 100-continue then send a header first
        send_only = ((req.is_a?(Post)||req.is_a?(Put)) && (req['expect']=='100-continue')) ? :header : nil
        req.exec @socket, @curr_http_version, edit_path(req.path), send_only
        begin
          res = HTTPResponse.read_new(@socket)
          # if we expected 100-continue then send a body
          if res.is_a?(HTTPContinue) && send_only && req['content-length'].to_i > 0
            req.exec @socket, @curr_http_version, edit_path(req.path), :body
          end
        end while res.kind_of?(HTTPContinue)
        res.reading_body(@socket, req.response_body_permitted?) {
          yield res if block_given?
        }
      end_transport req, res
      res
    end
  end

end