How to determine version of http in get html? - html

I want to request a server by 'get' and I use this method:
http://smarttracking.ir/gprmc_receiver.php?strVar=27,0,146,1,$GPRMC,213659.000,A,3238.0007,N,05118.5837,E,36.74,274.01,170114,,,N*6A5,username1,64,5}
If you copy this in the address bar on your browser, you will get a response. But there is a problem for me. I send this by sim900 module and it doesn't support http 1.0 or 1.1 and it is less than 1 so I need to send http version by address bar if it is possible. Something like this:
http://smarttracking.ir/gprmc_receiver.php?id=1 http/1.1 strVar=27,0,146,1,$GPRMC,213659.000,A,3238.0007,N,05118.5837,E,36.74,274.01,170114,,,N*6A5,username1,64,5}

Open a socket from the sim900 module to http://smarttraking.it and send a http request in according to the standard. The format of http request offers the possibility to specify the http version.
Look this image:
format http request

Related

Response code: 418 'I'm a teapot' in jmeter

I've been trying to test the API of restful-booker in Jmeter. But whenever I try to create a booking or Get a Booking by id I'm getting the HTTP response:418 'I'm a teapot'.If I try to access the URL in the browser it says the same. But when I run this in postman it does not give any kind of error. Also, it shows the correct response in Code Beautify. Really frustrating. Is there any way to resolve it?
If you're capable of successfully executing the request in postman (or whatever else tool) and not able to do it with JMeter most probably you're sending a different request.
Check out literally everything: URL, headers, body, etc. - all matters.
There are 2 approaches:
Use a 3rd-party sniffer tool like Fiddler or Burp to capture the requests from postman and JMeter and compare them for differences
Or just record the request from Postman using JMeter's HTTP(S) Test Script Recorder, JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
Problem is here: you forgot add accept: application/json in jmeter, postman automatically adds this setting.

Post request and get response robotframework

I need to send POST request and get json from it.
Create Http Context emopstest.pdc.org http
Set Request Header Content-Type application/x-www-form-urlencoded
Set Request Header Authorization Basic bG9naW46cGFzcw==
${dict}= Create Dictionary app_ids=18 where=ROWNUM<=2000
${value}= Stringify Json ${dict}
Set Request Body ${value}
HttpLibrary.HTTP.POST /auth_srv/services/auth/1/json/get_hazards
Show Response Body In Browser
Response Status Code Should Equal 200
${result_text}= Get Response Body
${result_json}= Parse Json ${result_text}
But this code returns to me 404...
What is wrong?
The 404 means that the server couldn't find the resource you requested. Usually that means the URL was wrong. Depending on how the server is configured, it could also mean that your authorization is wrong (ie: some applications will give a 404 in the case of bad authentication, so that an attacker isn't given a clue that the credentials are incorrect)
The server logs should have information that will help you track down whether you have an incorrect URL or that the server has a bug.

apache httpclient and etag cache

I'm using Apache HttpClient 4.3.1 and I'm trying to integrate etag validation cache.
I've tried to "drop in" httpclient-cache CachingHttpClientBuilder instead of my usual HttpClientBuilder using instructions in here, but that didn't seem to do any good. While tracing the execution, it seems like a response that has "etag" header (weak etag) isn't considered cache-able - and so isn't retained for the next cycle.
Has anyone managed to use etag validation based cache with Apache HttpClient? I'm also open for alternative implementations.
Notes:
The server returns the first request with a weak etag header (W/"1234"). If the second request to the same URL has "If-None-Match=1234", the server returns 304. This is checked and working.
The server does not send any other cache header (expires, etc).
The whole setup works wonderfully when using a modern browser.
Whether a response is considered as cacheable or not is decided in
ResponseCachingPolicy#isResponseCacheable(org.apache.http.HttpRequest, org.apache.http.HttpResponse)
which checks for some headers using
ResponseCachingPolicy#isExplicitlyCacheable
when
header 'Expires' is set or the header 'Cache-Control:' has one of the values "max-age" "s-maxage" "must-revalidate" "proxy-revalidate" or "public" the response is considered cacheable.
For us, it worked to add "Cache-Control: 'must-revalidate' to the response on the server, along with the 'Etag' header.
With this settings the apache http client
stores the response of the first request in the cache
on the second request, sends a request to the server and if this responds with a HttpStatus 304 (Not Modified) returns a HttpStatus 200 (ok) and the original content to the caller
That is how it should be.
We are using release 4.5.2 of apache http client cache.

Parse API GET Request

If I have a Parse.com API with applicationId APPLICATION_ID and REST-API-Key REST_API_KEY, and the classname is Story, then what should the GET request structure look like. I tried the following :
https://api.parse.com/1/story/applicationId=APPLICATION_ID&REST-API-Key=REST_API_KEY
but it didn't work.
#Das According to Parse API
Authentication is done via HTTP headers.
So, your request should be
*GET /1/stories/story HTTP/1.1
Host : api.parse.com
Accept: application/json
X-Parse-Application-Id: APPLICATION_ID
X-Parse-REST-API-Key: REST_API_KEY*
When we need to use headers, the Get request can not be formed within a single URL,
Postman chrome extension would be helpful to construct the requests
or fiddler.
When you are using postman, to fill the header details, take the HTTP Verb as POST and use
X-Http-Method-Override: GET header to make it a GET request.
Hope this helps

How does HTTP and HTML Work Together?

The answer to this little question will clear everything up for me.
If have a form tag that has a Get method and an action of some random script.
When I hit the submit button on the page, the Get Method is sent to HTTP and HTTP is what appends the query string to the url, the HTTP then returns a 20X status if the response is good and a 40X is a bad response? And our action goes to our webserver to run the script?
HTTP is transport and HTML is content. The Form submit calls a GET or POST request on the server depending on the action defined for the HTML form. The Form's arguments are appended by the Browser's form logic to the HTTP request, depending whehter GET or POST is used, they are attached to the request URL or put into the request body.
Then the request is handled on the server and the result is returned by the server logic (which can be a CGI, some perl script, a J2EE application etc.).
The server seponds with a HTTP status code (where everything below 300 is a success, and everything above 399 is an error - see here:HTTP staus codes ).
You are sending your form's data via HTTP using the "get" request. HTTP is a protocol and not a server. Your request is handled by a server who knows how to handle the HTTP protocol, eg. Apache.
The server processes the data and sends back a response. As you mention there are different kind of responses. 404 is best known (document not found).
The script is not run on the server, it is run on the client (the browser).
HTML is the markup code that describes the structure of the page. Browsers interpet the HTML code they receive and construct your page from it. Check here for more details: Wikipedia: HTML
The HTTP is the protocol used by the browser to talk to the server. Check this for more details: Wikipedia again: HTTP