@@ -788,7 +788,8 @@ int handle_curl_result(struct slot_results *results)
788788#define HTTP_REQUEST_STRBUF 0
789789#define HTTP_REQUEST_FILE 1
790790
791- static int http_request (const char * url , void * result , int target , int options )
791+ static int http_request (const char * url , struct strbuf * type ,
792+ void * result , int target , int options )
792793{
793794 struct active_request_slot * slot ;
794795 struct slot_results results ;
@@ -838,24 +839,37 @@ static int http_request(const char *url, void *result, int target, int options)
838839 ret = HTTP_START_FAILED ;
839840 }
840841
842+ if (type ) {
843+ char * t ;
844+ strbuf_reset (type );
845+ curl_easy_getinfo (slot -> curl , CURLINFO_CONTENT_TYPE , & t );
846+ if (t )
847+ strbuf_addstr (type , t );
848+ }
849+
841850 curl_slist_free_all (headers );
842851 strbuf_release (& buf );
843852
844853 return ret ;
845854}
846855
847- static int http_request_reauth (const char * url , void * result , int target ,
856+ static int http_request_reauth (const char * url ,
857+ struct strbuf * type ,
858+ void * result , int target ,
848859 int options )
849860{
850- int ret = http_request (url , result , target , options );
861+ int ret = http_request (url , type , result , target , options );
851862 if (ret != HTTP_REAUTH )
852863 return ret ;
853- return http_request (url , result , target , options );
864+ return http_request (url , type , result , target , options );
854865}
855866
856- int http_get_strbuf (const char * url , struct strbuf * result , int options )
867+ int http_get_strbuf (const char * url ,
868+ struct strbuf * type ,
869+ struct strbuf * result , int options )
857870{
858- return http_request_reauth (url , result , HTTP_REQUEST_STRBUF , options );
871+ return http_request_reauth (url , type , result ,
872+ HTTP_REQUEST_STRBUF , options );
859873}
860874
861875/*
@@ -878,7 +892,7 @@ static int http_get_file(const char *url, const char *filename, int options)
878892 goto cleanup ;
879893 }
880894
881- ret = http_request_reauth (url , result , HTTP_REQUEST_FILE , options );
895+ ret = http_request_reauth (url , NULL , result , HTTP_REQUEST_FILE , options );
882896 fclose (result );
883897
884898 if ((ret == HTTP_OK ) && move_temp_to_file (tmpfile .buf , filename ))
@@ -904,7 +918,7 @@ int http_fetch_ref(const char *base, struct ref *ref)
904918 int ret = -1 ;
905919
906920 url = quote_ref_url (base , ref -> name );
907- if (http_get_strbuf (url , & buffer , HTTP_NO_CACHE ) == HTTP_OK ) {
921+ if (http_get_strbuf (url , NULL , & buffer , HTTP_NO_CACHE ) == HTTP_OK ) {
908922 strbuf_rtrim (& buffer );
909923 if (buffer .len == 40 )
910924 ret = get_sha1_hex (buffer .buf , ref -> old_sha1 );
@@ -997,7 +1011,7 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head)
9971011 strbuf_addstr (& buf , "objects/info/packs" );
9981012 url = strbuf_detach (& buf , NULL );
9991013
1000- ret = http_get_strbuf (url , & buf , HTTP_NO_CACHE );
1014+ ret = http_get_strbuf (url , NULL , & buf , HTTP_NO_CACHE );
10011015 if (ret != HTTP_OK )
10021016 goto cleanup ;
10031017
0 commit comments