1. 07 4月, 2013 4 次提交
    • J
      http: drop http_error function · 4df13f69
      Jeff King 提交于
      This function is a single-liner and is only called from one
      place. Just inline it, which makes the code more obvious.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4df13f69
    • J
      http: re-word http error message · 39a570f2
      Jeff King 提交于
      When we report an http error code, we say something like:
      
        error: The requested URL reported failure: 403 Forbidden while accessing http://example.com/repo.git
      
      Everything between "error:" and "while" is written by curl,
      and the resulting sentence is hard to read (especially
      because there is no punctuation between curl's sentence and
      the remainder of ours). Instead, let's re-order this to give
      better flow:
      
        error: unable to access 'http://example.com/repo.git: The requested URL reported failure: 403 Forbidden
      
      This is still annoyingly long, but at least reads more
      clearly left to right.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      39a570f2
    • J
      http: simplify http_error helper function · 67d2a7b5
      Jeff King 提交于
      This helper function should really be a one-liner that
      prints an error message, but it has ended up unnecessarily
      complicated:
      
        1. We call error() directly when we fail to start the curl
           request, so we must later avoid printing a duplicate
           error in http_error().
      
           It would be much simpler in this case to just stuff the
           error message into our usual curl_errorstr buffer
           rather than printing it ourselves. This means that
           http_error does not even have to care about curl's exit
           value (the interesting part is in the errorstr buffer
           already).
      
        2. We return the "ret" value passed in to us, but none of
           the callers actually cares about our return value. We
           can just drop this entirely.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      67d2a7b5
    • J
      http: add HTTP_KEEP_ERROR option · 6d052d78
      Jeff King 提交于
      We currently set curl's FAILONERROR option, which means that
      any http failures are reported as curl errors, and the
      http body content from the server is thrown away.
      
      This patch introduces a new option to http_get_strbuf which
      specifies that the body content from a failed http response
      should be placed in the destination strbuf, where it can be
      accessed by the caller.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6d052d78
  2. 21 2月, 2013 1 次提交
  3. 06 2月, 2013 1 次提交
  4. 05 2月, 2013 1 次提交
    • S
      Verify Content-Type from smart HTTP servers · 4656bf47
      Shawn Pearce 提交于
      Before parsing a suspected smart-HTTP response verify the returned
      Content-Type matches the standard. This protects a client from
      attempting to process a payload that smells like a smart-HTTP
      server response.
      
      JGit has been doing this check on all responses since the dawn of
      time. I mistakenly failed to include it in git-core when smart HTTP
      was introduced. At the time I didn't know how to get the Content-Type
      from libcurl. I punted, meant to circle back and fix this, and just
      plain forgot about it.
      Signed-off-by: NShawn Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4656bf47
  5. 22 12月, 2012 1 次提交
  6. 20 10月, 2012 1 次提交
    • S
      Fix potential hang in https handshake · 7202b81f
      Stefan Zager 提交于
      It has been observed that curl_multi_timeout may return a very long
      timeout value (e.g., 294 seconds and some usec) just before
      curl_multi_fdset returns no file descriptors for reading.  The
      upshot is that select() will hang for a long time -- long enough for
      an https handshake to be dropped.  The observed behavior is that
      the git command will hang at the terminal and never transfer any
      data.
      
      This patch is a workaround for a probable bug in libcurl.  The bug
      only seems to manifest around a very specific set of circumstances:
      
      - curl version (from curl/curlver.h):
      
       #define LIBCURL_VERSION_NUM 0x071307
      
      - git-remote-https running on an ubuntu-lucid VM.
      - Connecting through squid proxy running on another VM.
      
      Interestingly, the problem doesn't manifest if a host connects
      through squid proxy running on localhost; only if the proxy is on
      a separate VM (not sure if the squid host needs to be on a separate
      physical machine).  That would seem to suggest that this issue
      is timing-sensitive.
      
      This patch is more or less in line with a recommendation in the
      curl docs about how to behave when curl_multi_fdset doesn't return
      and file descriptors:
      
      http://curl.haxx.se/libcurl/c/curl_multi_fdset.htmlSigned-off-by: NStefan Zager <szager@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7202b81f
  7. 13 10月, 2012 2 次提交
    • J
      http: do not set up curl auth after a 401 · 1960897e
      Jeff King 提交于
      When we get an http 401, we prompt for credentials and put
      them in our global credential struct. We also feed them to
      the curl handle that produced the 401, with the intent that
      they will be used on a retry.
      
      When the code was originally introduced in commit 42653c09,
      this was a necessary step. However, since dfa1725a, we always
      feed our global credential into every curl handle when we
      initialize the slot with get_active_slot. So every further
      request already feeds the credential to curl.
      
      Moreover, accessing the slot here is somewhat dubious. After
      the slot has produced a response, we don't actually control
      it any more.  If we are using curl_multi, it may even have
      been re-initialized to handle a different request.
      
      It just so happens that we will reuse the curl handle within
      the slot in such a case, and that because we only keep one
      global credential, it will be the one we want.  So the
      current code is not buggy, but it is misleading.
      
      By cleaning it up, we can remove the slot argument entirely
      from handle_curl_result, making it much more obvious that
      slots should not be accessed after they are marked as
      finished.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1960897e
    • J
      http: fix segfault in handle_curl_result · 188923f0
      Jeff King 提交于
      When we create an http active_request_slot, we can set its
      "results" pointer back to local storage. The http code will
      fill in the details of how the request went, and we can
      access those details even after the slot has been cleaned
      up.
      
      Commit 88097030 (http: factor out http error code handling)
      switched us from accessing our local results struct directly
      to accessing it via the "results" pointer of the slot. That
      means we're accessing the slot after it has been marked as
      finished, defeating the whole purpose of keeping the results
      storage separate.
      
      Most of the time this doesn't matter, as finishing the slot
      does not actually clean up the pointer. However, when using
      curl's multi interface with the dumb-http revision walker,
      we might actually start a new request before handing control
      back to the original caller. In that case, we may reuse the
      slot, zeroing its results pointer, and leading the original
      caller to segfault while looking for its results inside the
      slot.
      
      Instead, we need to pass a pointer to our local results
      storage to the handle_curl_result function, rather than
      relying on the pointer in the slot struct. This matches what
      the original code did before the refactoring (which did not
      use a separate function, and therefore just accessed the
      results struct directly).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      188923f0
  8. 21 9月, 2012 1 次提交
    • S
      Enable info/refs gzip decompression in HTTP client · aa90b969
      Shawn O. Pearce 提交于
      Some HTTP servers try to use gzip compression on the /info/refs
      request to save transfer bandwidth. Repositories with many tags
      may find the /info/refs request can be gzipped to be 50% of the
      original size due to the few but often repeated bytes used (hex
      SHA-1 and commonly digits in tag names).
      
      For most HTTP requests enable "Accept-Encoding: gzip" ensuring
      the /info/refs payload can use this encoding format.
      
      Only request gzip encoding from servers. Although deflate is
      supported by libcurl, most servers have standardized on gzip
      encoding for compression as that is what most browsers support.
      Asking for deflate increases request sizes by a few bytes, but is
      unlikely to ever be used by a server.
      
      Disable the Accept-Encoding header on probe RPCs as response bodies
      are supposed to be exactly 4 bytes long, "0000". The HTTP headers
      requesting and indicating compression use more space than the data
      transferred in the body.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aa90b969
  9. 28 8月, 2012 1 次提交
    • J
      http: factor out http error code handling · 88097030
      Jeff King 提交于
      Most of our http requests go through the http_request()
      interface, which does some nice post-processing on the
      results. In particular, it handles prompting for missing
      credentials as well as approving and rejecting valid or
      invalid credentials. Unfortunately, it only handles GET
      requests. Making it handle POSTs would be quite complex, so
      let's pull result handling code into its own function so
      that it can be reused from the POST code paths.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      88097030
  10. 24 8月, 2012 1 次提交
  11. 04 6月, 2012 1 次提交
  12. 01 5月, 2012 1 次提交
  13. 15 4月, 2012 2 次提交
    • J
      http: use newer curl options for setting credentials · 6f4c347c
      Jeff King 提交于
      We give the username and password to curl by sticking them
      in a buffer of the form "user:pass" and handing the result
      to CURLOPT_USERPWD. Since curl 7.19.1, there is a split
      mechanism, where you can specify each element individually.
      
      This has the advantage that a username can contain a ":"
      character. It also is less code for us, since we can hand
      our strings over to curl directly. And since curl 7.17.0 and
      higher promise to copy the strings for us, we we don't even
      have to worry about memory ownership issues.
      
      Unfortunately, we have to keep the ugly code for old curl
      around, but as it is now nicely #if'd out, we can easily get
      rid of it when we decide that 7.19.1 is "old enough".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6f4c347c
    • J
      http: clean up leak in init_curl_http_auth · aa0834a0
      Jeff King 提交于
      When we have a credential to give to curl, we must copy it
      into a "user:pass" buffer and then hand the buffer to curl.
      Old versions of curl did not copy the buffer, and we were
      expected to keep it valid. Newer versions of curl will copy
      the buffer.
      
      Our solution was to use a strbuf and detach it, giving
      ownership of the resulting buffer to curl. However, this
      meant that we were leaking the buffer on newer versions of
      curl, since curl was just copying it and throwing away the
      string we passed. Furthermore, when we replaced a
      credential (e.g., because our original one was rejected), we
      were also leaking on both old and new versions of curl.
      
      This got even worse in the last patch, which started
      replacing the credential (and thus leaking) on every http
      request.
      
      Instead, let's use a static buffer to make the ownership
      more clear and less leaky.  We already keep a static "struct
      credential", so we are only handling a single credential at
      a time, anyway.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aa0834a0
  14. 11 4月, 2012 1 次提交
    • J
      fix http auth with multiple curl handles · dfa1725a
      Jeff King 提交于
      HTTP authentication is currently handled by get_refs and fetch_ref, but
      not by fetch_object, fetch_pack or fetch_alternates. In the
      single-threaded case, this is not an issue, since get_refs is always
      called first. It recognigzes the 401 and prompts the user for
      credentials, which will then be used subsequently.
      
      If the curl multi interface is used, however, only the multi handle used
      by get_refs will have credentials configured. Requests made by other
      handles fail with an authentication error.
      
      Fix this by setting CURLOPT_USERPWD whenever a slot is requested.
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dfa1725a
  15. 28 3月, 2012 1 次提交
  16. 03 3月, 2012 1 次提交
    • N
      http: support proxies that require authentication · dd613997
      Nelson Benitez Leon 提交于
      When the proxy server specified by the http.proxy configuration or the
      http_proxy environment variable requires authentication, git failed to
      connect to the proxy, because we did not configure the cURL handle with
      CURLOPT_PROXYAUTH.
      
      When a proxy is in use, and you tell git that the proxy requires
      authentication by having username in the http.proxy configuration, an
      extra request needs to be made to the proxy to find out what
      authentication method it supports, as this patch uses CURLAUTH_ANY to let
      the library pick the most secure method supported by the proxy server.
      
      The extra round-trip adds extra latency, but relieves the user from the
      burden to configure a specific authentication method.  If it becomes
      problem, a later patch could add a configuration option to specify what
      method to use, but let's start simple for the time being.
      Signed-off-by: NNelson Benitez Leon <nbenitezl@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd613997
  17. 14 12月, 2011 1 次提交
    • J
      http-push: enable "proactive auth" · a4ddbc33
      Jeff King 提交于
      Before commit 986bbc08, git was proactive about asking for
      http passwords. It assumed that if you had a username in
      your URL, you would also want a password, and asked for it
      before making any http requests.
      
      However, this could interfere with the use of .netrc (see
      986bbc08 for details). And it was also unnecessary, since
      the http fetching code had learned to recognize an HTTP 401
      and prompt the user then. Furthermore, the proactive prompt
      could interfere with the usage of .netrc (see 986bbc08 for
      details).
      
      Unfortunately, the http push-over-DAV code never learned to
      recognize HTTP 401, and so was broken by this change. This
      patch does a quick fix of re-enabling the "proactive auth"
      strategy only for http-push, leaving the dumb http fetch and
      smart-http as-is.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a4ddbc33
  18. 12 12月, 2011 1 次提交
    • J
      http: use credential API to get passwords · 148bb6a7
      Jeff King 提交于
      This patch converts the http code to use the new credential
      API, both for http authentication as well as for getting
      certificate passwords.
      
      Most of the code change is simply variable naming (the
      passwords are now contained inside the credential struct)
      or deletion of obsolete code (the credential code handles
      URL parsing and prompting for us).
      
      The behavior should be the same, with one exception: the
      credential code will prompt with a description based on the
      credential components. Therefore, the old prompt of:
      
        Username for 'example.com':
        Password for 'example.com':
      
      now looks like:
      
        Username for 'https://example.com/repo.git':
        Password for 'https://user@example.com/repo.git':
      
      Note that we include more information in each line,
      specifically:
      
        1. We now include the protocol. While more noisy, this is
           an important part of knowing what you are accessing
           (especially if you care about http vs https).
      
        2. We include the username in the password prompt. This is
           not a big deal when you have just been prompted for it,
           but the username may also come from the remote's URL
           (and after future patches, from configuration or
           credential helpers).  In that case, it's a nice
           reminder of the user for which you're giving the
           password.
      
        3. We include the path component of the URL. In many
           cases, the user won't care about this and it's simply
           noise (i.e., they'll use the same credential for a
           whole site). However, that is part of a larger
           question, which is whether path components should be
           part of credential context, both for prompting and for
           lookup by storage helpers. That issue will be addressed
           as a whole in a future patch.
      
      Similarly, for unlocking certificates, we used to say:
      
        Certificate Password for 'example.com':
      
      and we now say:
      
        Password for 'cert:///path/to/certificate':
      
      Showing the path to the client certificate makes more sense,
      as that is what you are unlocking, not "example.com".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      148bb6a7
  19. 16 11月, 2011 1 次提交
  20. 05 11月, 2011 5 次提交
  21. 16 10月, 2011 2 次提交
    • J
      http_init: accept separate URL parameter · deba4937
      Jeff King 提交于
      The http_init function takes a "struct remote". Part of its
      initialization procedure is to look at the remote's url and
      grab some auth-related parameters. However, using the url
      included in the remote is:
      
        - wrong; the remote-curl helper may have a separate,
          unrelated URL (e.g., from remote.*.pushurl). Looking at
          the remote's configured url is incorrect.
      
        - incomplete; http-fetch doesn't have a remote, so passes
          NULL. So http_init never gets to see the URL we are
          actually going to use.
      
        - cumbersome; http-push has a similar problem to
          http-fetch, but actually builds a fake remote just to
          pass in the URL.
      
      Instead, let's just add a separate URL parameter to
      http_init, and all three callsites can pass in the
      appropriate information.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      deba4937
    • M
      http: use hostname in credential description · 070b4dd5
      Michael J Gruber 提交于
      Until now, a request for an http password looked like:
      
        Username:
        Password:
      
      Now it will look like:
      
        Username for 'example.com':
        Password for 'example.com':
      
      Picked-from: Jeff King <peff@peff.net>
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      070b4dd5
  22. 07 9月, 2011 2 次提交
  23. 04 8月, 2011 1 次提交
  24. 21 7月, 2011 2 次提交
  25. 04 6月, 2011 1 次提交
  26. 05 5月, 2011 1 次提交
  27. 27 4月, 2011 1 次提交
  28. 27 11月, 2010 1 次提交