Forum Discussion

Aditya_Mehra's avatar
Jul 24, 2018

\r\n causing bad requests to the server

Receive a bad 400 request from the server.

 

The iapp piece of code is as below

 

set send_data \"GET \$api_url\r\nHTTP/1.1\r\nHost: \$api_host\r\n\r\n\"

 

On the packet capture the bad request goes like below in 3 lines.

 

GET $api_url

 

HTTP/1.1

 

Host: $api_host

 

But the success request goes in two lines as below:

 

GET $api_url HTTP/1.1

 

Host: $api_host

 

QUESTION : what can be edited in \r\n ??

 

2 Replies

  • You should not have a \r\n before the HTTP/1.1:

    set send_data \"GET /$api_url HTTP/1.1\r\nHost: $api_host\r\n\r\n\"

    That is the difference between

    GET $api_url
    
    HTTP/1.1 
    Host: $api_host
    

    and

    GET $api_url HTTP/1.1 
    Host: $api_host