Skip to content

Commit

Permalink
Force application/x-www-form-urlencoded for GET requests + layout fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nebolsin committed Jun 25, 2015
1 parent 2bf0753 commit b19d89c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion features/html_generation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Feature: html generation
And I fill in the submit form field "name" with "Jim"
Then I should see:
"""
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d 'user%5Bname%5D=Jim'
curl -X POST -d 'user%5Bname%5D=Jim'
"""

And I submit lurk form
Expand Down
2 changes: 1 addition & 1 deletion lib/lurker/presenters/service_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def to_html(&block)
end

def title
name
"#{name}"
end

def domains
Expand Down
4 changes: 3 additions & 1 deletion lib/lurker/templates/javascripts/lurker.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
results.push('curl');
results.push('-X ' + method);
if (serializedPayload.length > 0) {
results.push("-H 'Content-Type: " + contentType + "'");
if (contentType != 'application/x-www-form-urlencoded') {
results.push("-H 'Content-Type: " + contentType + "'");
}
results.push("-d '" + serializedPayload + "'");
}
results.push("'" + targetUrl + "'");
Expand Down
7 changes: 5 additions & 2 deletions lib/lurker/templates/lurker/rendering/_submit_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
requestMediaTypes: JSON.parse('<%= @service_presenter.request_media_types.to_json.html_safe %>'),
requestMediaType: '<%= @service_presenter.default_request_media_type %>'
};

if (state.method === 'GET') {
state.requestMediaType = 'application/x-www-form-urlencoded';
state.requestMediaTypes = [state.requestMediaType];
}
return this.autodetectLocalhost(state);
},

Expand Down Expand Up @@ -86,7 +89,7 @@
</select>
</div>
</div>
<% if @service_presenter.request_media_types.size > 1 %>
<% if @endpoint_presenter.verb != 'GET' && @service_presenter.request_media_types.size > 1 %>
<div className="form-group">
<label className="control-label col-sm-3" forHtml="requestMediaType">Request Media Type</label>
<div className="col-sm-9">
Expand Down

0 comments on commit b19d89c

Please sign in to comment.