Is it possible to control request data? - iis

I want to control request content(GET,POST) on IIS side. Is that possible? By control I mean filter characters or strings. Also is it possible to to check if request has only certain list of variables(e.g foo and bar for request http://site?foo=a&bar=b).

Related

tabulator question - Why is it requested multiple times when using ajax?

ajaxLoader:true,
ajaxFiltering:true,
ajaxProgressiveLoad:"scroll",
ajaxProgressiveLoadDelay:200,
ajaxConfig:"POST",
ajaxProgressiveLoadScrollMargin : 10,
I used the above settings and worked in the order below.
clearFilter();
addFilter()
setData()
At this time, 3 requests occur.
One request with no filter applied.
The filter applied has been requested twice.
What's the problem?
That is correct operation of the table. You have Ajax filtering enabled in your settings.
When you clear the filters a request must be made to retrieve the unfiltered data.
Then when you add a filter it must request the filtered data.
Then when you change the data URL with set data it makes another request.
If all you want to do is set a filter then there is no need to call clearFilter then addFilter then setData, you can simply call setFilter which will do all of the above in one action with one request.
table.setFilter("age", "=”, 12);
You only need to call the setData function in this instance if you want to change the base url of the request.
An explanation of this can be found in the first section of the Filter Documentation

How can I avoid querying the same data twice when I require 2 http responses (one a file, one a json object)?

I have the following layout. If the Export to Excel checkbox is not checked, upon the button being pressed an API call will be made to query the data in the date range, and displayed in d3 graphs below. If it is checked, the button makes the same API call, in addition to referencing a 2nd call that downloads an Excel file. I think these 2 separate calls are necessary because I need the data in both forms (json and an attachment) which both require separate headers. I wasn't able to figure out a way to make just one call and return the data both ways, but if that's possible I would be open to that solution. Otherwise, what are my options to query the data just once, and share it between both calls?
A HTTP request can only respond with one response type. So with a single request you can only return json or excel (whatever encoding you used). When you click that button and the excel checkbox is checked, do you need both responses? Or just the file?
If you just want the file, then ignore the JSON and do not update your d3 graphs.
If you want the graphs and the file, you'll have to make two requests, one for the JSON and one for the file. If you want to only process that DB call once on the server, you'd need something else. Like, return the JSON data and store the file at a link you'll know the address to. Or return the file and push the JSON to the client (WebSocket or similar).
If you can cache on the server (caching DB like redis or in-memory if you can guarantee you'll hit the same server node), you could store/hash the query parameters with the returned data. Any future call would check that cache first and maybe not hit the DB. (Of course, be aware that if any data would update the results, you'll need to kill your cache key so the data is requeried).

how to determine body tags in http request

I have a number of answer options that are being sent to the server with names "answer1", "answer2" etc. The number of answer options is set by the user in the browser. Is there any way to access their values without manually typing req.body.answer1, req.body.answer2?
Use an array instead: answer[].
When appending the name with square brackets it will automatically be converted to an Array that you can access via req.body.answer.

Combine multiple http request or not?

Some web design questions.
Combine POST with GET?
When user clicks a button, I need to send one POST to submit a form, then need to GET a json object to replace some DOM fields. Should I combine them into one request so save one round trip time?
Multiple GET json request?
When user clicks a button, I need to GET 3 or 4 json object. Should I send 3 or 4 GET request, or just one and combine the json into one large json at back-end?
So basically, I'm not sure which is heavier: round trip time VS a little complexed back-end and front-end logic.
Any comment is welcome!
if i understood your question right...you have a dependency on your get requests...that is to say the second get depends on the first...if that is the case, obviously you need to take consecutive get operations...however, if that is not the case that is if you know the order of get request and the response won't be affected by local conditions...then i suggest you do post/get operations on server side...trigger the first one an let the server handle the rest and get the result...
of course you would not want users do multiple get requests for one simple operation...

What's the appropriate Response Code for a Pagination API using a GET Request with page parameters, where the parameters produce no records?

I have developed a Web Interface for a db. The db and Web Interface are for my own use in my hobby running on my private intranet. Currently the db has 1800+ records which is going to increase with usage. Ver 1 of the Web Interface listed all records (~2.5KB) on a single page requiring a ton of scrolling. Vers 2 of the Web interface introduced pagination where records are grouped into a non-fixed size of roughly 100 records. On page load all 1800+ records are still transferred to the client but only the first page is "visible", the other 17 are hidden. I use a series of "non-submit" buttons with JS on-click functionality to hid the current page and make the selected page visible. Better in that scrolling is limited to ~100 records. Vers 3 only transfers the first page and the paging buttons on page load. Now, the on-click function using fetch() API sends a GET Request with parameters to fetch the desired page then swaps it into the DOM. The parameters specify a starting and ending points for the page. These values come from the paging buttons supplied by the server on page load. Works well with significantly reduced data transfer size. In Vers 4 I am generalize the fetch() API GET Request parameters to send user specified parameters to allow the user to choose any page starting and ending point. (Note: The user can not specify a page size directly.) So if the user selects a start and end point that no records fall into my plan is to use HTTP Response Code 204 "No Content" to tell the JS code that there are no matching records and nothing to swap. Is this the appropriate Response Code? Should I be including any other Header information in the Response with the 204 code?
Take a look at what the RFC says about 204:
https://www.rfc-editor.org/rfc/rfc7231#section-6.3.5
It's really intended for PUT requests. I think for what you are doing, it's fine to return 200 and no body, with a Content-Length header of 0.

Resources