Skip to content
  • Ray's avatar
    http*: add helper methods for fetching objects (loose) · 5424bc55
    Ray authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The code handling the fetching of loose objects in http-push.c and
    http-walker.c have been refactored into new methods and a new struct
    (object_http_request) in http.c. They are not meant to be invoked
    elsewhere.
    
    The new methods in http.c are
     - new_http_object_request
     - process_http_object_request
     - finish_http_object_request
     - abort_http_object_request
     - release_http_object_request
    
    and the new struct is http_object_request.
    
    RANGER_HEADER_SIZE and no_pragma_header is no longer made available
    outside of http.c, since after the above changes, there are no other
    instances of usage outside of http.c.
    
    Remove members of the transfer_request struct in http-push.c and
    http-walker.c, including filename, real_sha1 and zret, as they are used
    no longer used.
    
    Move the methods append_remote_object_url() and get_remote_object_url()
    from http-push.c to http.c. Additionally, get_remote_object_url() is no
    longer defined only when USE_CURL_MULTI is defined, since
    non-USE_CURL_MULTI code in http.c uses it (namely, in
    new_http_object_request()).
    
    Refactor code from http-push.c::start_fetch_loose() and
    http-walker.c::start_object_fetch_request() that deals with the details
    of coming up with the filename to store the retrieved object, resuming
    a previously aborted request, and making a new curl request, into a new
    function, new_http_object_request().
    
    Refactor code from http-walker.c::process_object_request() into the
    function, process_http_object_request().
    
    Refactor code from http-push.c::finish_request() and
    http-walker.c::finish_object_request() into a new function,
    finish_http_object_request(). It returns the result of the
    move_temp_to_file() invocation.
    
    Add a function, release_http_object_request(), which cleans up object
    request data. http-push.c and http-walker.c invoke this function
    separately; http-push.c::release_request() and
    http-walker.c::release_object_request() do not invoke this function.
    
    Add a function, abort_http_object_request(), which unlink()s the object
    file and invokes release_http_object_request(). Update
    http-walker.c::abort_object_request() to use this.
    
    Signed-off-by: default avatarTay Ray Chuan <rctay89@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    5424bc55