HTTP/HTTPS 통신연습 → HEAD Request
The following commands show how to send HTTP HEAD requests to the server, and how to read HTTP responses.
HEAD request is used to only get HTTP response header from the server,
we use this method mainly to test if we can connect to the server successfully.
1. HTTP-HEAD 명령시퀀스
NO | Command | Response | 설명 |
1 | PDP Context 설정 | ||
2 | AT+HTTPINIT | OK |
(1) PDP Context 활성화 (2) HTTP Service 시작 |
3 | AT+HTTPPARA=”URL”,”http://ipinfo.io” | OK | HTTP 통신 |
– | AT+HTTPPARA=”URL”,”https://ipinfo.io” | OK | HTTPS 통신 |
4 | AT+HTTPACTION=2 |
+HTTPACTION: 2,200,375 +HTTP_PEER_CLOSED |
Head Request |
5 | AT+HTTPHEAD | +HTTPHEAD: DATA,375 HTTP/1.0 200 OK access-control-allow-origin: * x-frame-options: SAMEORIGIN x-xss-protection: 1; mode=block x-content-type-options: nosniff referrer-policy: strict-origin-when-cross-origin content-type: application/json; charset=utf-8 content-length: 292 date: Sat, 27 Nov 2021 07:51:57 GMT x-envoy-upstream-service-time: 1 vary: Accept-Encoding Via: 1.1 googleOK |
Read Head |
6 | AT+HTTPTERM | OK | Stop HTTP Service |
2. HTTP Server 참조
IP 정보 | https://ipinfo.io | |
날씨정보 | http://www.kma.go.kr | |
Test Server | https://httpbin.org | |
https://httpbin.org/anything | Returns most of the below. | |
https://httpbin.org/ip | Returns Origin IP. | |
https://httpbin.org/user-agent | Returns user-agent. | |
https://httpbin.org/headers | Returns header dict. | |
https://httpbin.org/get | Returns POST data. | |
https://httpbin.org/put | Returns PUT data. | |
https://httpbin.org/delete | Returns DELETE data | |
https://httpbin.org/gzip | Returns gzip-encoded data. | |
https://httpbin.org/status/:code | Returns given HTTP Status code. | |
https://httpbin.org/response-headers?key=val | Returns given response headers. | |
https://httpbin.org/redirect/:n | 302 Redirects n times. | |
https://httpbin.org/relative-redirect/:n | 302 Relative redirects n times. | |
https://httpbin.org/cookies | Returns cookie data. | |
https://httpbin.org/cookies/set/:name/:value | Sets a simple cookie. | |
https://httpbin.org/basic-auth/:user/:passwd | Challenges HTTPBasic Auth. | |
https://httpbin.org/hidden-basic-auth/:user/:passwd | 404’d BasicAuth. | |
https://httpbin.org/digest-auth/:qop/:user/:passwd | Challenges HTTP Digest Auth. | |
https://httpbin.org/stream/:n | Streams n–100 lines. | |
https://httpbin.org/delay/:n | Delays responding for n–10 seconds. |