logo elektroda
logo elektroda
X
logo elektroda

GET request from esp8266 onet.co.uk returns error 400 Bad Request

BARVX 1332 4
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16924457
    BARVX
    Level 6  
    Does anyone know what the query should look like?
    I send the query from the esp8266 module.

    When sending the query to nbp.pl using GET http://nbp.pl HTTP/1.0 everything works the page returns the html code. When I want to use the same query (GET http://onet.pl HTTP/1.0) to get the html code of onet.co.uk it returns me this:
    Code: HTML, XML
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #2 16924554
    excray
    Level 41  
    Perhaps blandly. Perhaps it's the server that can't identify who is asking (desktop or mobile device) and doesn't know what version to send. Maybe try querying the site: https://m.onet.pl/ - mobile version
  • ADVERTISEMENT
  • #3 16924703
    JacekCz
    Level 42  
    excray wrote:
    Maybe bland. Perhaps it's the server not being able to identify who is asking (desktop or mobile device) and doesn't know what version to send. Maybe try querying the site: https://m.onet.pl/ - mobile version
    .

    Something from this climate. Or a large site running on a load balancer, address group etc etc etc....
    If I were to analyse a similar topic, I would check the options from my PC with the http command line client, wget or whatever.

    The colleague loses the biggest flavour, the description added to the HTTP code, and you don't see him intercepting that code in the call, sometimes helpful. The 400 code posted in HTML, however, is no longer that.
  • ADVERTISEMENT
  • #4 16931535
    krzbor
    Level 28  
    Most likely something is missing in the header. Perhaps it doesn't match 1.0 and expects 1.1?
    Here is an example from old IE:
    GET / HTTP/1.1
    Accept: */*
    Accept-Language: pl
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
    Accept-Encoding: gzip, deflate
    Host: onet.pl
    Connection: Keep-Alive
    
    .

    However, even if you do get it:

    Code: HTML, XML
    Log in, to see the code
    .

    Simply put, onet works over https (https://www.onet.pl).
  • #5 16932032
    aso824
    Level 13  
    The domain onet.pl is not accessible over HTTP, only over HTTPS - the error code returned is HTTP/1.1 301 Moved Permanently:

    Code: Bash
    Log in, to see the code
    .

    The above occurs for both HTTP 1.0 and 1.1.
    However, the attempted request to nbp.pl looks like this:

    Code: Bash
    Log in, to see the code
    .

    At first glance the error seems obscure, but note where the server wants to redirect - just add "www" to the host in the request to get a normal response:

    Code: Bash
    Log in, to see the code
    .

    PS. It's a good idea to add "Connection: close" to the request at the end, then the server won't try to keep-alive in the case of HTTP 1.1
ADVERTISEMENT