What is the best way to check if http GET response content is valid with? - bash

I want to check that i got all the content and not just a part of it. If the http header is OK, does it mean that all the content is also OK?
So far i have been using Bash and wget command.

Look for status code 200. According the W3's documentation, status code 200 received in response to a GET requests means the request succeeded and the response is and is returned in the response.
Someone could write an API that returns garbage and still sends status code 200. If you are just getting a file/document from a Web server, then the status codes are probably very trustworthy.

If you want to have a look at the response body to check all your content is there you could use tools like Fiddler or IExplorer F12, wireshark. As #ahoffer mentions if status is 200 ok then the server is giving you what you requested.

Related

why some http requests are showing no response data in j meter?

When I run a Http Request, to a page that should return a response body. When I execute the sampler it's sends a 200 OK code, but the response body in the View Results Tree Listener, is empty. Why does this happen?
It does happen because the system under test doesn't send any response body so you're asking the wrong people about the possible reasons.
If you can reproduce is with the real browser or other tool like curl - you need to raise an issue against the system you're testing because it must be functionally stable before you can start executing performance tests.
If you cannot reproduce it with a real browser - make sure to configure JMeter to behave like a real browser, i.e. add HTTP Header Manager and set it up to send the same headers that the browser does.

Status 200 ok giving blank response

I am working on spring cloud project, getting status 200 ok status but the response body is empty for the APIs. Can any one help me to resolve the issue?
Thanks & Regards
Anita PAtil
Status is different from the Response vody. Response Body depends on what you are returning or binding any data to the Response Body. Know about HTTP Response status line, headers and body and the difference between them. The status here Indicates that Server accepted the request or there is an aasociated action method in the server to respond.

What is the HTTP status code to return when input data is missing?

I have written a REST API in nodejs.
I want to send HTTP status codes on various events.
For example when data is returned I send HTTP code 200.
What is the status code to return when the input data is missing?
This isn't specific to nodejs. HTTP status codes are general -- you can read about them on wikipedia:
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
I think you want client error code 400, which means Bad Request.
Perhaps you should return 404, not found. As mentioned in previous answer, HTTP status codes are general.
A tip: try getting grip on HTTP before starting off web development.

codeception get request with if-none-match does not return 304

i am using codeception for the code coverage of a REST API. In my current case, i want to test the behaviour of sending a request to receive an ETag-Header for the requested resource and reuse the value of this ETag in a second request on the same resource with the header "If-None-Match" to achieve a 304 response code.
So what I am doing in my Cest-File is:
// send first request, grab etag
$I->sendGET('/myresource');
$I->seeResponseCodeIs(200);
$I->seeHttpHeader('ETag');
$eTag = $I->grabHttpHeader('ETag');
// send second request with header "If-None-Match" containing the etag
$I->haveHttpHeader('If-None-Match', $eTag);
$I->sendGET('/myresource');
$I->seeHttpHeader('ETag');
$I->seeResponseCodeIs(304);
When I execute this test it fails after the second request saying that response code 200 does not match 304.
When I execute the same request with an external tool (HTTP Requester Plugin for Firefox), i get the expected behaviour. What do i have to do to get my tests working? Am i mssing something on the codeception side or may this be a bug?
Any help is appreciated, maybe someone already had this scenario before.
Thanks in advance for your help!

How to prevent the server from replying with 304?

I need to know the steps that I can do to prevent the server from replying with 304.
Your client is probably sending an 'If-Modified-Since' header. Don't send it and you should be fine.
The intent of the header and the 304 reply is that if the client already has the latest data (as per the header 'If-Modified-Since'), there is no point in downloading it again.
The server will send a 304 if the content has not been modified since a particular date. That date is set via the client's IF_MODIFIED_SINCE header. See here for more details.
I recognized that It is not a good idea to do so.
However, If you need to do so, You can put some filter in the server to reset the value of IF_MODIFIED_SINCE request tag.

Resources