If you request html webpage that has some text and an image, I believe http uses 2 responses for that of type text/html and image/html. Are both the http responses put in the same TCP response or not?
I would think that would be the most efficient way to do it unless the server expects another request for the image. Which brings me to my next question, does the server expect multiple requests for each http response or can it just send all the http responses that are needed for the html page?
ie.
TCP (GET /)
TCP (HTTP response 1, response 2, response 3)
Also can the tcp response have a fraction of one http response? For example if it is larger than the max packet size.
Typically, images have their own URLs. In HTTP/1.x, only the client can initiate a request. Even though the server might know that the client would need a resource, it has no way to send it to the client and must wait to receive a request for the resource from the client. Thus, images are fetched through a separate HTTP request, and thus get a separate HTTP response.
TCP Connections per HTTP request:
With regard to a TCP connection, a single connection can be used for multiple HTTP requests, for example in case several images are being fetched from the same server. However, this still requires a FIFO queue of requests and responses. Thus, browsers prefer separate TCP connections per HTTP request.
TCP Packets per HTTP request:
A single HTTP request/response can span across multiple TCP packets, if they don't fit in a single packet. Think of a 1 GB file upload or download request - its a single request/response, that would span over multiple packets.
When the server and client support "persistent connection" (Connection: keep-alive), then multiple HTTP requests can be pipelined in a single TCP packet, if they can fit in.
Try this:
(echo "HEAD /index.html HTTP/1.1\nHost: www.google.co.in\nConnection: keep-alive\n\nHEAD /index.html HTTP/1.1\nHost: www.google.co.in\n\n"; sleep 1) | telnet www.google.co.in 80
The two pipelined HEAD requests evidently fit in a single packet.
In general, I wouldn't worry if HTTP request(s) are payloaded in single/multiple TCP packet(s), and leave that to the TCP protocol. Same holds for HTTP response.
While you are on this subject, I would recommend some reading on HTTP/2 as well :)
Related
i recorded script with jmeter for 4 transactions.launch, logon, continue, logoff. i am seeing redirecting error for continue transaction and for that i am not seeing any response for that all request. But i am seeing response data in jmeter for all request for continue transaction. i have id token value and that i want to substitute for the next request as post.
Continue transaction
request..response (i am seeing response data with ID_token in jmeter but not in browser)
request (ID_Token as posting here) - Need to get final response for continue transaction.
As per Redirections in HTTP guide:
In HTTP, redirection is triggered by a server sending a special redirect response to a request. Redirect responses have status codes that start with 3, and a Location header holding the URL to redirect to.
As per RFC 2616 the response body is not required for 3xx redirect responses, moreover for 304 Not Modified status it's even forbidden so it's absolutely fine to not to have response body for 3xx status codes as long as you have Location header which points you to the next page.
Just make sure that JMeter sends the same requests and they're treated in the same manner by the server as requests from the real browser by comparing request flow in your browser developer tools and the ones which are sent by JMeter. In case of mismatch play with Redirect automatically and Follow redirects checkboxes in HTTP Request sampler or in HTTP Request Defaults configuration element:
I am using AppMon 6.5 to monitor an application running in Oracle Weblogic with an Apache server as web server.
The clients perform a lot of HTTP POST requests with json payload and I would like to capture the sent data.
I have configured Web Server sensor (Apache agent) to capture all request headers and request parameters and the Servlet sensor (Weblogic agent) to capture all request headers, request parameters, session attributes...
But I am able to capture only the POST parameters when the clients send the parameters as form-data (e.g. login request consists in two post parameters sent as form-data)
The documentation of Web server sensor states this
Request Parameter Capturing
Capturing the request parameter has some limitations on the web server:
Only the first 20.000 characters of the combined string of query and POST body will be analyzed. Parameters which are beyond that limit cannot be captured.
Reading request parameters from the POST body is only supported for IIS7+ and Apache based web servers.
https://community.dynatrace.com/community/display/DOCDT65/Web+Server+Sensor
Is it not possible to capture the POST data sent as body (e.g json content)??
Thanks in advance
Regards.
Dynatrace AppMon does not capture Payload data, it would cause a high overhead. For almost all situations you can get the information you want another way though, e.g. via method arguments.
I'm working on an HTTP parser and was wondering how can i parse traffic that is sent with no content length and no EOF?
Read the data until the connection is shutdown (from the other side).
This is how the original HTTP worked, but it's not very nice; if the server crashes, or you lose network connectivity in the middle of the transmission, you might not notice that the response is truncated.
How do you know if a socket server or web server is done transmitting a HTTP GET request when using ProgressEvent.SOCKET_DATA ?
I doing my socket request with socket.writeUTFBytes('GET /index.php HTTP/1.1\r\n');
But the 'answer' is so big that i get multiple ProgressEvent.SOCKET_DATA. How do i know how much data it is supposed to transmit to me ? Or when it's done transmitting ?? Or even how many progressEvents i will get out of this request ? So far I'm using a timer that checks if the server is still transmitting but this isn't a very clean way of doing things..
How do i know how much data it is supposed to transmit to me? Or when it's done transmitting ??
By reading the Content-length header if that is sent by the server, or by waiting until the server closes the connection, or by reading until you've encountered a last-chunk (0<CRLF><CRLF>) if chunked transfer encoding is enabled, or any of the other indications that a full response has been received.
For simplicity, use a HTTPService or if that doesn't fit your needs, use a library that implements an HTTP client.
Or even how many progressEvents i will get out of this request ?
There is no way to tell.
I used sharppcap to capture TCP packets. Now i wanna reconstruct HTTP packet from TCP packets but i don't know how. I read somewhere i can find start of HTTP packet in TCP data... i tried to convert byte[] TCP data to string using this code:
string s = System.Text.Encoding.UTF8.GetString(tcp_pack.Data);
but the string isn't readable. like a binary file that is opened with notepad.
is it because the data is encrypted or code is incorrect?
how can i reconstruct HTTP packet from TCP packets?
try "Encoding.BigEndianUnicode.GetString(tcp_pack.Data)"
There is no easy way do to this because you'll need to reconstruct the TCP session in memory.
Essentially, if a message being sent is larger than one packet, it's broken up into multiple packets. Therefore, you'll need to capture those packets, arrange them in the right order, and reassemble the data manually.
If the message is short/simple and doesn't get broken up into multiple parts then you'll need to find out what format the payload is in. Try decoding in ASCII first.