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

StubbyClient works but no other HttpClient or Browser #13

Closed
ashishsharma09 opened this issue Mar 28, 2013 · 10 comments
Closed

StubbyClient works but no other HttpClient or Browser #13

ashishsharma09 opened this issue Mar 28, 2013 · 10 comments
Labels

Comments

@ashishsharma09
Copy link

With stubbyClient.startJetty only stubbyClient.doGet works. When I try to access the configured URL from Browser or using apache HttpClient or HttpConnection, the response is 404. Why the jetty server started through stubbyClient not visible to other APIs.

@azagniotov
Copy link
Owner

Cheers,
Will have a look

Delivered to you from my iDevice

On Mar 28, 2013, at 4:16 PM, ashishsharma09 notifications@github.com wrote:

With stubbyClient.startJetty only stubbyClient.doGet works. When I try to access the configured URL from Browser or using apache HttpClient or HttpConnection, the response is 404. Why the jetty server started through stubbyClient not visible to other APIs.


Reply to this email directly or view it on GitHub.

@ashishsharma09
Copy link
Author

I eventually found out it's the query string that is causing the problem, not sure though why that is working with stubbyClient but not with apache HttpClient or browser. The query string parameter that is causing the problem is as follows:
attributes: '["id","uuid","created","lastUpdated","displayName","email","givenName","familyName"]'. So my config.yaml looks like:

-  request:
      method: GET
      url: /entity.find
      query:
         type_name: user
         client_id: id
         client_secret: secret
         attributes: '["id","uuid","created","lastUpdated","displayName","email","givenName","familyName"]'
   response:
      status: 200
      file: entity-find-response.json
      headers:
         content-type: application/json

If I remove the "attributes" parameter above it works all right. But with it I get 404 on accessing from browser or apache HttpGet. Please note single quotes around the value for "attributes". If I remove it, stubbyClient starts returning 404 as well.

@ashishsharma09
Copy link
Author

Hi,

Has anyone had a chance to look into it yet? I think I have found what was causing the problem. It's the double quotes in the query parameter which causes the problem (took me good two days with lots of trial and error to figure it out). I was initially wrongly assuming it's the '[]' brackets. So following is my finding:

attributes: ["id"] - fails with 404.
attributes: '["id"]'- fails from browser and any other http client api. Works with StubbyClient only.
attributes: '[%22id%22]' - makes browser and everyone else happy.

I would expect it to work with ["id"] as this is more sensible and readable. If you get a chance please give it a go and let me know what you think.

FYI - I tried file: as well in the request but that did not help either.

Thanks,
Ashish

@mrak
Copy link
Collaborator

mrak commented Apr 4, 2013

It looks as if query-string parameters are not being URI-encoded while loading them into the system (or at least not at all entry points).

Sorry for the lack of "official" responses. We've been tied down at work lately. Flagging this as a bug.

Also edited a couple of the comments here to make the code portions more readable.

@azagniotov
Copy link
Owner

I am looking into this... Stay tuned

@azagniotov
Copy link
Owner

Ok... I have put a fix in place for the scenario when query string contains array with elements within as per your example. I have tested both for:
http://localhost:8882/entity.find?type_name=user&client_id=id&client_secret=secret&attributes=["id","uuid","created","lastUpdated","displayName","email","givenName","familyName"]
and
http://localhost:8882/entity.find.again?type_name=user&client_id=id&client_secret=secret&attributes=[id,uuid,created,lastUpdated,displayName,email,givenName,familyName]

Works both when making request programmatically via StubbyClient and browser. The bug will be resolved in v1.0.59. Will push it to Maven Central shortly

@azagniotov
Copy link
Owner

You can continue using your original configuration:

-  request:
      method: GET
      url: /entity.find
      query:
         type_name: user
         client_id: id
         client_secret: secret
         attributes: '["id","uuid","created","lastUpdated","displayName","email","givenName","familyName"]'
   response:
      status: 200
      file: entity-find-response.json
      headers:
         content-type: application/json

In other words, no need to replace double quotes with %22 in you YAML

@azagniotov
Copy link
Owner

I am closing the ticket for now, but please report if the problem is still persists.

@ashishsharma09
Copy link
Author

Hi,

Thanks for putting the fix in place so quickly. I will pick up the new version and try as soon as possible. Can't wait to see my yaml look pretty again. Will keep you posted...

Thanks,
Ashish

@azagniotov
Copy link
Owner

Hi Ashish,

Just in case, I am also supporting for:
http://localhost:8882/entity.find.single.quote?type_name=user&client_id=id&client_secret=secret&attributes=['id','uuid','created']
where array elements are enclosed with single quotes

Just get the latest version of stubby

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

No branches or pull requests

3 participants