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

Allow requests to local domains. #27

Open
gvino opened this issue Aug 20, 2013 · 9 comments
Open

Allow requests to local domains. #27

gvino opened this issue Aug 20, 2013 · 9 comments

Comments

@gvino
Copy link

gvino commented Aug 20, 2013

Now when I tried to send request to http:https://test-server.dev/login, for example I see an error:

{
    "class": "NSError",
    "code": 3840,
    "domain": "NSCocoaErrorDomain",
    "reason": "The data has been corrupted."
}
@youknowone
Copy link
Owner

VisualJSON doesn't determine your URL is local or not. I usually use this application with localhost. Could you open the URL with other application? I guess if safari can open it, VisualJSON also opens it.

@gvino
Copy link
Author

gvino commented Aug 20, 2013

Now I test this service with Poster addon to Firefox and it works fine, so it's a bug in VisualJSON.
2013-08-20 19 49 32

@youknowone
Copy link
Owner

Firefox use non-OS connection - but I don't think you set it up different network environment.
I still don't know what is happening. I can connect to any server listed in /etc/host
Do you have any idea to allow me to test your environment or replicate it to my machine?

@gvino
Copy link
Author

gvino commented Aug 21, 2013

Safari opens this host too.

To replicate my environment you need to have:

  • rvm
  • ruby 1.9.3 installed through rvm
  • Pow

With this up and running:

$ mkdir /sinatra/app/path
$ echo '1.9.3' > /sinatra/app/path/.ruby-version && echo 'my-test-gemset' > /sinatra/app/path/.ruby-gemset
$ cd /sinatra/app/path
$ rvm env > .powenv
$ gem install powder && gem install sinatra && gem install sinatra-contrib
$ touch server.rb && touch config.ru

In server.rb:

require 'sinatra'
require 'sinatra/json'

post '/login' do
    params.inspect
    if params[:email] == '[email protected]' and params[:password] == '123qwe'
        [200, json({status: 'ok'})]
    else
        [401, json({status: 'login information is incorrect'})]
    end
end

get '/*:format?' do
    params.inspect
end

In config.ru:

require './server'
run Sinatra::Application

After all do in terminal inside folder with config.ru

$ powder link

Now you can open in Safari your sinatra app with URL given by Pow.

@paranoicsan
Copy link

Have same behavior when server responds with 400 Bad Request.

When a server being tested responds with 200 - response is shown under the Tree section. When the response code is 400 - I have the same error as @gvino wrote.

@gvino
Copy link
Author

gvino commented Aug 28, 2013

It looks like you drop all responses, except 200.

@youknowone
Copy link
Owner

#28 seems solve this problem

@youknowone
Copy link
Owner

@youknowone youknowone reopened this Sep 1, 2013
@vburlak
Copy link

vburlak commented Oct 13, 2014

@youknowone hmm. same bug.. using last VisualJSON from App Store Version 1.6.0 (1.6.0)

Have project running on localhost( MAMP ) & remote test server.
Queries to localhost have 3840 error, and queries to test server have success..

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

No branches or pull requests

4 participants