FAQ
Hi all,

I'm having an issue figuring out how to make an HTTP request without having
the http client automatically attempt redirecting.

I'm doing this because I'm working with a REST API that uses HTTP redirects
(302) to point to various resources, and I'd like to grab the 302 response,
process it, and extract the URL for later processing (but not follow it).

Here's my code as it stands,
currently: http://pastie.org/private/bolqvhxghxkpwngwgbc4a

I can't help but feel that there is a better way to do this. Treating an
HTTP redirect like an error seems... weird. I don't want to do that.

I saw another post on this group from a while back
(https://groups.google.com/forum/#!topic/golang-nuts/PmYm3h2J3FE) which
talks about this -- but I couldn't figure out how to make the suggested
solution work.

Could anyone give me an example of what I need to do to make the HTTP
client *not* attempt to follow redirects?

Thank you!


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Naitik Shah at Apr 26, 2014 at 3:02 am
    Something like this: http://play.golang.org/p/mbtcF2mJai
    On Fri, Apr 25, 2014 at 8:22 AM, wrote:
    Hi all,

    I'm having an issue figuring out how to make an HTTP request without having
    the http client automatically attempt redirecting.

    I'm doing this because I'm working with a REST API that uses HTTP redirects
    (302) to point to various resources, and I'd like to grab the 302 response,
    process it, and extract the URL for later processing (but not follow it).

    Here's my code as it stands, currently:
    http://pastie.org/private/bolqvhxghxkpwngwgbc4a

    I can't help but feel that there is a better way to do this. Treating an
    HTTP redirect like an error seems... weird. I don't want to do that.

    I saw another post on this group from a while back
    (https://groups.google.com/forum/#!topic/golang-nuts/PmYm3h2J3FE) which
    talks about this -- but I couldn't figure out how to make the suggested
    solution work.

    Could anyone give me an example of what I need to do to make the HTTP client
    *not* attempt to follow redirects?

    Thank you!


    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    -Naitik

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Martin Angers at Apr 26, 2014 at 9:15 pm
    error should be nil for a valid response though (regardless of status code).

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 26, '14 at 2:35a
activeApr 26, '14 at 9:15p
posts3
users3
websitegolang.org

3 users in discussion

R: 1 post Naitik Shah: 1 post Martin Angers: 1 post

People

Translate

site design / logo © 2021 Grokbase