Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(HTTPoison.Error) :closed needs a proper message that its from hackney #432

Closed
dkuku opened this issue Apr 11, 2021 · 3 comments
Closed

Comments

@dkuku
Copy link

dkuku commented Apr 11, 2021

I have an error with "https://www.sejm.gov.pl/", (HTTPoison.Error) :closed
I can get to google with HTTPPoison (iex(3)) and this url: https://www.sejm.gov.pl/ with curl works just fine iex(2)
Steps to reproduce:


iex(1)> HTTPoison.start                                                                                                
{:ok, []} 

iex(2)> response = HTTPoison.get! "https://www.sejm.gov.pl/Sejm9.nsf/poslowie.xsp?type=A"                              
** (HTTPoison.Error) :closed (httpoison 1.8.0) lib/httpoison.ex:156: HTTPoison.request!/5

iex(2)> System.cmd("curl", ["https://www.sejm.gov.pl/Sejm9.nsf/poslowie.xsp?type=A"])    
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current   Dload  Upload   Total   Spent    Left  Speed
      100       172k        100         172k                0             0        523k      0      --:--:--  --:--:--   --:--:--  523k
{"<!DOCTYPE html>\n<html lang=\"pl\">\n<head>\n<script type=\"text/javascript">if(!navigator.cookieEnabled)window.location.href=\"https://www.sejm.gov.pl/Sejm9.nsf/poslowie.xsp?type=A\\u0026SessionID=36746C5A545C5C7741821F66E90B55DD0CA7419E\";</script>\n<title>Aktualni pos&#322;owie</title>\n<link rel=\"SHORTCUT ICON\" href=\"https://www.sejm.gov.pl/favicon.ico\">\n<meta name=\"charset\" content=\"utf-8\">pocz&#261;tek sw&oacute;j bierze\n      z woli\n      narodu\"</span><h2 class=\"wcag-hide\">Menu ...,

iex(3)> response = HTTPoison.get! "https://google.com"                                    
%HTTPoison.Response{
  body: "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>301 Moved</TITLE></HEAD><BODY>\n<H1>301 Moved</H1>\nThe document has moved\n<A HREF=\"https://www.google.com/\">here</A>.\r\n</BODY></HTML>

I saw an old post from 2018 that it may be a hackney issue - and the solution was to upgrade hackney.
#326
So even if it is hackney - we should probably handle it and show some kind of message to the user

@dkuku dkuku changed the title error with "https://www.sejm.gov.pl/", (HTTPoison.Error) :closed (HTTPoison.Error) :closed needs a proper message that its from hackney Apr 11, 2021
@edgurgel
Copy link
Owner

Hi @dkuku ,

What do you mean by handle it? If you use .get instead of .get! you should get a proper HTTPoison.Error. Is that what you mean?

@dkuku
Copy link
Author

dkuku commented Apr 12, 2021

I scrolled the wrong command in iex - I was using get before when I pasted the initial title

I was thinking more of pointing the user that the error comes from hackney - I only found it out only because I saw that its using hackney and I checked if it works in hackney, The original atom is converted to string anyway so it would be good to add something that points to hackney instead just wrapping it in a struct because its a bit confusing.
maybe hackney returned: and the reason

@edgurgel
Copy link
Owner

edgurgel commented Apr 12, 2021

The README.md very clearly states that we use hackney under the hood. I don't see us changing the return of a function so that people are aware of which libs are used. I think it's part of the research that people should do around using open source libraries. Thanks for opening the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants