Empty Line error while sending GET request from fiddler - tcp

I wrote following line in Fiddler Composer>Raw tab and pressed execute,
GET /api.php/phy/3 HTTP/1.1\r\nHOST: maz4579.esy.es:80\r\n\r\n
but it says that the HTTP request is incomplete. Please ensure that there is single empty line after headers.

Fiddler's Composer doesn't attempt to decode \r\n into a carriage-return line-feed pair. Instead, just hit the enter key after each line.

Related

HTTP 403 Forbidden Message Format

What is the correct format for sending an HTTP 403 forbidden message?
I'm writing a proxy in c for a homework project that has a content filtering system built in. When my proxy detects that a server's response has certain keywords that are contained in the content blacklist, I would like to send a HTTP 403 Forbidden message.
Currently, I am sending the message as: "HTTP/1.1 403 Forbidden\r\n\r\n" (without the quotes) as per this standard: https://www.rfc-editor.org/rfc/rfc7231#section-6.5.3
When I send this message, the browser doesn't display an error and looks like it's still trying to load the page.
Are there any required header fields for this http message that I missed? Also, is this the correct usage for the 403 error? I couldn't find anything else that would be more fitting, so I chose 403 because the client won't automatically re-request the data.
Thanks in advance for any help!
For those struggling with this issue as I did, you need to make sure to close the socket or set Connection: Close as Sami noted in the comments. I assumed that you could keep it open so they could send another request with http persistent connections, but they will need to open a new connection.
As for the html displayed, you can send a body with the response (make sure you set Content-Length) that contains the html you want displayed.
Finally, here are two references, one to the HTTP response spec, and the other to the Amazon Restful response spec:
https://www.rfc-editor.org/rfc/rfc7231#section-6.5.3
https://developer.amazon.com/docs/amazon-drive/ad-restful-api-response-codes.html

Are multiple status code headers allowed in a single HTTP response?

I have a web app which sends HTTP status codes. In some instances, a 404 code is sent as a header, but then a 200 error is sent as well, in the same response.
HTTP/1.0 404 Not Found
HTTP/1.0 200 Ok
I can't change the execution order to prevent the first status code from being sent, so the second code is attempting to override it.
Chrome ignores the first code and assumes the status to be Ok. Does this conform to the HTTP standard, and should I rely on it?
No, it does not conform to the standard, and you should not rely on it. See https://www.greenbytes.de/tech/webdav/rfc7230.html#rfc.section.5.6:
More than one response message per request only occurs when one or more informational responses (1xx, see Section 6.2 of [RFC7231]) precede a final answer to the same request.
The rfc for http 1.1 is given here: https://www.rfc-editor.org/rfc/rfc7230
Section 2.1 states:
A server responds to a client's request by sending one or more HTTP
response messages, each beginning with a status line ...
The standard states that you can send more than one response, if you wish, but that each response must have it's own status line. Further, the first line of the header must contain the status-line/code.
So, according to the standard interpreted literally, in theory you can send more than one response, but I've no idea what browsers would do with that, and definitely wouldn't rely on it.
What you've got at the moment is conforming to the rfc; the rfc doesn't say you can't have more than status line, only that the status line on the first line of each response is the one that matters - which chrome doesn't interpret correctly according to the rfc.
It might work, but I wouldn't rely on it.

SIM5216 Command AT+CHTTPSSEND

I'm trying to receive data from a website using Arduino and Sim5216 3g board.
The AT+CHTTPSSEND requires the following information (Taken from the example in the SIM5216 manual)
"AT+CMMSSEND=88"
">GET / HTTP/1.1 "
"Host:www.mywebsite.com"
"User-Agent: MY WEB AGENT "
"Content-Length: 0"
What is the "User-Agent"? From what I searched, it represents the browser you are using. I'm inclined to leave it blank, however when I do that, once I enter the command with the other info filled out, I get no response. The sim5216 board doesn't respond anymore and I have to press the reset button to get any further responses from it (even if I type AT, I don't get an ok unless I reset the board).
Any comments/help is much appreciated.
Thanks,
Check my tutorial HTTPS GET request with SIM5215E!
Just don't care about User-Agent for now. It represents browser you are using, but it doesn't matter for success of GET request.

Error in receiving httpget respponse

I am using GSM module (M95 Quectel). As per given example of Send HTTP GET Request in Quectel http command manual, I am sending the command but in the end I failed to get a response from the server side. Its show the following error when sending:
send AT+QHTTPGET
+CME ERROR 3827
How can I get the correct response and read the data?
The QHTTPGET command should be sent with the to_read_time variable. for example:
AT+QHTTPGET=60 please check if this is what you are doing.
In addition, you can check the URL you are trying to perform the GET request to in chrome, by entering it and view the response to check server validity.
Also, you can try checking if you mannage to perform a GET request to a test server such as in here:
HTTP Test server that accepts GET/Post calls

Response does not start with HTTP

Attached Firefox to fiddler and got following error. What would cause this error?
Interesting thing to note is that the HTTP header is getting rendered on the page
So Fiddler says that there is a protocol violation because response does not start with HTTP. But the HTTP response is rendered on page.
it is likely that some page content, especially one that has a blank line, is displayed before the HTTP header info is displayed. In such case, the browser will think it was the end of the HTTP header section and render those characters as content.
(your attachment's link is broken now so can't see any info there)
You can use telnet to see precisely what the server is returning. If you are running the server on port 800, try this:
$ telnet hostname 800
GET / HTTP/1.0
(You need to hit enter twice after the GET line. You can also add headers at that point if you need to.)
and assuming a leading blank line is the problem, you'd see something like
(blank line)
HTTP/1.1 200 OK
Various-headers: here
The server is not sending things out correctly. A valid HTTP response would be the HTTP headers, followed by an empty line and then the content. In this case, it seems likely that this was not followed. If there was an empty line before the HTTP headers, the HTTP headers would just be treated like content and rendered accordingly.

Resources