FAQ
Hi,

net/http request's have a SetBasicAuth() method defined that sets the HTTP
Basic Authentication
Authorization header, I've found it convenient to have it's opposite number
for the responses, i.e.

func (r *Response) GetBasicAuth() (username string, password string, err
error)

Would this be a welcome addition to net/http ?

I've attached a diff with a naive implementation, and some basic tests.

--

Search Discussions

  • Brad Fitzpatrick at Nov 6, 2012 at 9:20 am
    Maybe. I'm not sure this is worth it. We try not to add everything in the
    world to the standard library.

    But it would be called BasicAuth() probably, without "Get" (which we avoid
    using whenever possible). Feel free to send it in as a codereview
    following http://golang.org/doc/contribute.html to get a discussion going
    on golang-dev. httputil might even be the best place. Maybe http is okay,
    given the existing setter precedent.
    On Tue, Nov 6, 2012 at 9:27 AM, thorduri wrote:

    Hi,

    net/http request's have a SetBasicAuth() method defined that sets the HTTP
    Basic Authentication
    Authorization header, I've found it convenient to have it's opposite
    number for the responses, i.e.

    func (r *Response) GetBasicAuth() (username string, password string, err
    error)

    Would this be a welcome addition to net/http ?

    I've attached a diff with a naive implementation, and some basic tests.

    --

    --
  • Thorduri at Nov 6, 2012 at 9:49 am

    On Tuesday, November 6, 2012 10:20:11 AM UTC+1, bradfitz wrote:
    Maybe. I'm not sure this is worth it. We try not to add everything in
    the world to the standard library.
    Noted.

    But it would be called BasicAuth() probably, without "Get" (which we avoid
    using whenever possible). Feel free to send it in as a codereview
    following http://golang.org/doc/contribute.html to get a discussion going
    on golang-dev. httputil might even be the best place. Maybe http is okay,
    given the existing setter precedent.
    I will, thanks.

    FWIW, I think it makes more sense in http, as you say given the existing
    setter precedent.

    On a related note, I have a few additions like this and others, for example
    for net/rpc's debug page I've added error counts and
    a slice of callers/timeof tuples as well as being able to request the stats
    in JSON format. I've found this to be useful when prototyping and
    it's 'small' enough for the standard library IMO.

    Does it make sense to send those right away as a code review?

    On Tue, Nov 6, 2012 at 9:27 AM, thorduri <thor...@secnorth.net <javascript:>
    wrote:
    Hi,

    net/http request's have a SetBasicAuth() method defined that sets the
    HTTP Basic Authentication
    Authorization header, I've found it convenient to have it's opposite
    number for the responses, i.e.

    func (r *Response) GetBasicAuth() (username string, password string, err
    error)

    Would this be a welcome addition to net/http ?

    I've attached a diff with a naive implementation, and some basic tests.

    --

    --
  • Brad Fitzpatrick at Nov 6, 2012 at 9:55 am

    On Tue, Nov 6, 2012 at 10:49 AM, thorduri wrote:

    On a related note, I have a few additions like this and others, for
    example for net/rpc's debug page I've added error counts and
    a slice of callers/timeof tuples as well as being able to request the
    stats in JSON format. I've found this to be useful when prototyping and
    it's 'small' enough for the standard library IMO.

    Does it make sense to send those right away as a code review?
    Might as well. Once you learn the codereview process, it's easy to send
    out patches for review, and you'll want to learn it at some point anyway if
    you plan to get anything submitted. So little harm in proposing something
    that's not accepted.

    --
  • Blake at Nov 7, 2012 at 7:43 pm
    I would love to see BasicAuth in net/http. I don't see a ticket in the
    tracker. When you create it, please let me know.
    On Tuesday, November 6, 2012 1:55:15 AM UTC-8, bradfitz wrote:

    On Tue, Nov 6, 2012 at 10:49 AM, thorduri <thor...@secnorth.net<javascript:>
    wrote:
    On a related note, I have a few additions like this and others, for
    example for net/rpc's debug page I've added error counts and
    a slice of callers/timeof tuples as well as being able to request the
    stats in JSON format. I've found this to be useful when prototyping and
    it's 'small' enough for the standard library IMO.

    Does it make sense to send those right away as a code review?
    Might as well. Once you learn the codereview process, it's easy to send
    out patches for review, and you'll want to learn it at some point anyway if
    you plan to get anything submitted. So little harm in proposing something
    that's not accepted.
    --
  • Victorcoder at Nov 8, 2012 at 8:21 am
    +1
    On Wednesday, November 7, 2012 8:43:33 PM UTC+1, bl...@heroku.com wrote:

    I would love to see BasicAuth in net/http. I don't see a ticket in the
    tracker. When you create it, please let me know.
    On Tuesday, November 6, 2012 1:55:15 AM UTC-8, bradfitz wrote:
    On Tue, Nov 6, 2012 at 10:49 AM, thorduri wrote:

    On a related note, I have a few additions like this and others, for
    example for net/rpc's debug page I've added error counts and
    a slice of callers/timeof tuples as well as being able to request the
    stats in JSON format. I've found this to be useful when prototyping and
    it's 'small' enough for the standard library IMO.

    Does it make sense to send those right away as a code review?
    Might as well. Once you learn the codereview process, it's easy to send
    out patches for review, and you'll want to learn it at some point anyway if
    you plan to get anything submitted. So little harm in proposing something
    that's not accepted.
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 6, '12 at 8:27a
activeNov 8, '12 at 8:21a
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase