2

I'm trying to make a simple python script which returns an argument from GET request. The issue is that it does not receive any arguments and returns blank body. There is one peculiar thing, though. In order to test GET requests I use requestmaker.com, hurl.it and apikitchen.com. While requestmaker and apikitchen return an empty body, hurl.it actually returns the required parameter.

I have tried Bottle, Flask and Tornado with the same results. I'm using ngrok for tunneling but I've also tried forwardhq.com.

The code (with bottle framework):

import bottle
from bottle import route, run, request, response

bottle.debug(True)

@route('/')
def home():
    return "Great Scott!"

@route('/valley')
def thevalley():
    theflux = request.query.flux
    return theflux

run(host='0.0.0.0', port=8515, reloader=True)

ngrok status:

Tunnel Status                 online
Version                       1.6/1.5
Forwarding                    http://88mph.ngrok.com -> 127.0.0.1:8515

The results I get from GET requests:

requestmaker.com

Request Headers Sent:

GET /valley HTTP/1.1
Host: 88mph.ngrok.com
Accept: */*
Content-Length: 10
Content-Type: application/x-www-form-urlencoded

Response Headers:

HTTP/1.1 200 OK
Server: nginx/1.4.3
Date: Sun, 09 Feb 2014 13:51:20 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive

bottle:

127.0.0.1 - - [09/Feb/2014 13:51:20] "GET /valley HTTP/1.1" 200 0

hurl.it

Request:

Accept: */*
Accept-Encoding: gzip, deflate, compress
User-Agent: runscope/0.1

Response:

Connection: keep-alive
Content-Length: 5
Content-Type: text/html; charset=UTF-8
Date: Sun, 09 Feb 2014 14:02:55 GMT
Server: nginx/1.4.3

Body:

121gw

bottle:

127.0.0.1 - - [09/Feb/2014 14:02:55] "GET /valley?flux=121gw HTTP/1.1" 200 5

https://88mph.ngrok.com/valley?flux=121gw

Finally, just entering the URL into the address bar works as well, I get "121gw".

bottle:

127.0.0.1 - - [09/Feb/2014 14:05:46] "GET /valley?flux=121gw HTTP/1.1" 200 5

End

Every request maker can connect to server (200 OK) and even return "Great Scott" when accessing root. However, only webbrowser and hurl return the argument. Any ideas what is at fault here?

zvisofer
  • 1,346
  • 18
  • 41
moosatov
  • 21
  • 3
  • did you try `request.query.get('flux')`? – vaultah Feb 09 '14 at 14:24
  • I did. The exact same results. I've also tried `request.query_string`, which returns "flux=121gw" in hurl.it and browser, but is empty for other two. – moosatov Feb 09 '14 at 14:38
  • Requestmaker handles GETs weird. It shouldn't send a Content-Length or Content-Type header since GETs can't have bodies. If you put the full URL into the URL there (instead of putting the data in the 'Request Data' (which puts it in the request body instead of the URL) box I'm guessing you'll see it. – John Sheehan Feb 10 '14 at 06:57
  • @RunscopeAPITools Thanks! This makes sense. It does work from URL box. – moosatov Feb 10 '14 at 11:35
  • @RunscopeAPITools Can you help with a follow-up question? https://stackoverflow.com/questions/21678517/identical-post-requests-for-tag-subscription-yield-different-results – moosatov Feb 10 '14 at 13:26

0 Answers0