Note that there are some explanatory texts on larger screens.

plurals
  1. POHTSQL shell's Get Request Not compatible with Gunicorn+Nginx for long queries
    primarykey
    data
    text
    <p>I am using HTSQL with Django. I use HTSQL shell to check/generate my queries and then use them for rendering data in json and raw formats. so like, my HTSQL shell url is:</p> <pre><code>http://127.0.0.1:8000/htsql </code></pre> <p>so when I want to access data from a table in the HTSQL shell environment, I do,</p> <pre><code>http://127.0.0.1:8000/htsql/table_name </code></pre> <p>and to get JSON data,</p> <pre><code>http://127.0.0.1:8000/htsql/table_name/:json </code></pre> <p>In background, HTSQL shell fetches this data by using a GET request. So from my client-side Javascipt/jQuery, I initiate a GET request with its URL in above format and get my desired JSON data directly.</p> <p>Everything was fine when I was using local Django server, but when I deployed my project using Gunicorn and Nginx, it naturally started to block some of my long(actually, pretty long) queries in the GET requests. I searched this problem and found out that Gunicorn allows GET request values ranging from 0 to 8190 characters. So I tweaked my Gunicorn settings for the maximum limit but still the same problem. This was because my queries, when used with several filter values, are exceeding 8190 limit.</p> <p>So I thought to use POST request as its normally preferred for secure and long requests. So I changed my GET request to POST request and pointed it to the same URL as mentioned above and tried it on my local Django Server(i.e without Gunicorn and Nginx). But now I get "400 BAD REQUEST". With firebug, I checked that the response was "POST requests are not permitted."</p> <p>I also noticed that the HTSQL_Django Module routes all the request to htsql_django.views.gateway. I had a look to this gateway function in the views.py of htsql_django module but couldn't find any clue.</p> <p>Is it so, that the HTSQL doesn't accepts POST requests?? How can I fetch/access JSON data from HTSQL using POST request?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYou might consider putting large query fragments as in your configuration file using tweak.override as either class-labels or field-labels. This will not only keep your URLs sane, but, will provide quite lovely re-use of commonly used (and perhaps quite large) fragments.
      singulars
    2. COI got your point clarkevans, but my problem is a bit different. My query is getting big due to the filter values. Like, table_name.filter(field_name={'AAAAAAA','BBBBBBBB','CCCCCCCCC',......}). (and my each field_name value char length is much larger than the example above). And these multiple filter values are selected on the run time by the user which are, in some cases, many many values which makes my query too large. So, the reusable parts are insignificant(in terms of number of characters) as compared to the filter data values. I don't have any option left but to use POST request.
      singulars
    3. COThank you for explaining. In this case, just permitting POST won't do the trick since the URL will still be too long. Perhaps a solution would be to make a POST-to-Query gateway that takes an 'application/htsql' body, executes it, and returns the result?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload