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

All I get is "nil". #36

Closed
ghost opened this issue Mar 23, 2011 · 14 comments
Closed

All I get is "nil". #36

ghost opened this issue Mar 23, 2011 · 14 comments

Comments

@ghost
Copy link

ghost commented Mar 23, 2011

Hello,

Can someone of you help me out with Gist? I've installed it through Homebrew, and I have set my username and token inside my ~/.gitconfig file.

However, I'm completely unable to paste anything to the gist command. Is there any way for me to debug this?

Should be some ways for the command to check what is wrong, instead for spit out "nil".

@indirect
Copy link
Collaborator

Maybe try the gem version of gist, via gem install gist? At least then you can try loading up the gist library in IRB and use it to see what's going on.

@ghost
Copy link
Author

ghost commented Apr 10, 2011

Not sure how to do it. But the gem version outputted "nil" as well.

Oh well, copy & paste works as well ;)

@indirect
Copy link
Collaborator

I'm sorry you're having trouble -- I don't really have any ideas. It works just fine for me both standalone and as a gem.

@ghost
Copy link
Author

ghost commented Apr 12, 2011

I would really love to know how I can debug this. Not fluent with Ruby at all. And I'm not sure how to utilize the gem.

@indirect
Copy link
Collaborator

okay, here's how to manually use the gem:

$ gem install gist
Successfully installed gist-2.0.2
1 gem installed

$ irb
>> require 'gist'
=> true
>> Gist.write [:input => "testing"], true
=> "https://gist.github.com/e6586a128773f71e47e8"

@ghost
Copy link
Author

ghost commented Apr 12, 2011

Thank you so much!

But, yet nil is still displayed. No error message at all.

Oh well, I don't want to take more of your time :) Thank for the help. Much appreciated ;)

@indirect
Copy link
Collaborator

Very strange. That means that, somehow, the HTTP request to gist.github.com is completing without an error, but the response is not including a "Location" header. I take it the gist that you are trying to create is not actually showing up at gist.github.com?

@indirect indirect reopened this Apr 12, 2011
@indirect
Copy link
Collaborator

Okay, this is really bugging me. So here is an example of manually putting through a request to the gist server, using the gist gem to set up the data for the request. When you do this, if you copy and paste the response to return to me, please X out the "token" value, and the "_gh_sess" value (like I did below) so that they can't be used to steal your github account.

$ irb

>> require 'gist'
=> true
>> irb Gist
>>     url = URI.parse(CREATE_URL)
=> #<URI::HTTPS:0x103293840 URL:https://gist.github.com/gists>
>>     if PROXY_HOST
>>         proxy = Net::HTTP::Proxy(PROXY_HOST, PROXY_PORT)
>>         http  = proxy.new(url.host, url.port)
>>       else
?>           http = Net::HTTP.new(url.host, url.port)
>>       end
=> #<Net::HTTP gist.github.com:443 open=false>
>>     http.use_ssl = true
=> true
>>     http.verify_mode = OpenSSL::SSL::VERIFY_PEER
=> 1
>>     http.cert = OpenSSL::X509::Certificate.new(ca_cert)
=> #<OpenSSL::X509::Certificate subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority, issuer=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority, serial=3558802160848854062232407011527417280, not_before=Wed Nov 09 00:00:00 UTC 1994, not_after=Thu Jan 07 23:59:59 UTC 2010>
>>     req = Net::HTTP::Post.new(url.path)
=> #<Net::HTTP::Post POST>
>> req.form_data = data([:input => "testing"], true)
=> {"file_contents[gistfile1]"=>"testing", "file_ext[gistfile1]"=>".txt", "file_name[gistfile1]"=>nil, :token=>"xxxx", "action_button"=>"private", :login=>"indirect"}
>> response = http.start{|h| h.request(req) }
=> #<Net::HTTPFound 302 Found readbody=true>
>> response["Location"]
=> "https://gist.github.com/5a821a0efed442100453"
>> response.each_header{}
=> {"strict-transport-security"=>["max-age=2592000"], "location"=>["https://gist.github.com/5a821a0efed442100453"], "connection"=>["keep-alive"], "content-type"=>["text/html; charset=utf-8"], "x-runtime"=>["312ms"], "date"=>["Tue, 12 Apr 2011 17:43:53 GMT"], "server"=>["nginx/0.7.67"], "content-length"=>["110"], "set-cookie"=>["_gh_sess=xxxx; path=/; expires=Fri, 01 Jan 2021 00:00:00 GMT; secure; HttpOnly"], "cache-control"=>["no-cache"], "status"=>["302 Found"]}

@ghost
Copy link
Author

ghost commented Apr 22, 2011

Using the latest commit, I where able to track down the problem to be my token were wrong :) Since I had changed my password a while back.

Thank you :)

However, when I gisted my .vimrc file it, I had the strange error Creating gist failed: 302 "Found", yet the Gist were created.

@indirect
Copy link
Collaborator

Ah! Good catch... 302 found actually means the gist worked! Sounds like the patch I pulled doesn't handle that case correctly. :) Thanks!

@indirect
Copy link
Collaborator

Fixed in 284dd9b.

@ghost
Copy link
Author

ghost commented Apr 22, 2011

How come I don't see the commit, nor can pull it?

@indirect
Copy link
Collaborator

Because I'm silly, and pushed to my fork but not the main repo :) Fixed now!

@ghost
Copy link
Author

ghost commented Apr 22, 2011

Thank you :)

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

1 participant