Skip to content

Commit 1188bd0

Browse files
author
Roberto De Ioris
authored
Update Http_API.md
1 parent 9a8e1b8 commit 1188bd0

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

docs/Http_API.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The HTTP API
2-
-
2+
=
33

44
The IHttpRequest and IHttpResponse interfaces are exposed as Python classes (both inheriting from IHttpBase)
55

@@ -78,3 +78,67 @@ response = request.get_response()
7878
data = json.loads(response.get_content_as_string())
7979
ue.log(data['user-agent'])
8080
```
81+
82+
In case of long running requests, another event can be bound:
83+
84+
```python
85+
from unreal_engine import IHttpRequest
86+
import json
87+
88+
request = IHttpRequest('GET', 'http://httpbin.org/user-agent')
89+
90+
def response_received(request, response, success):
91+
data = json.loads(response.get_content_as_string())
92+
ue.log(data['user-agent'])
93+
94+
def request_progress(request, sent, received):
95+
ue.log(sent)
96+
ue.log(received)
97+
98+
# bind OnProcessRequestComplete event to the response_received callable
99+
request.bind_on_process_request_complete(response_received)
100+
101+
request.bind_on_request_progress(response_received)
102+
103+
# run the request
104+
request.process_request()
105+
```
106+
107+
Exposed methods for IHttpBase (inherited by IHttpRequest and IHttpResponse)
108+
-
109+
110+
111+
### get_content()
112+
113+
returns the payload of the request/response
114+
115+
### get_all_headers()
116+
117+
returns a the list of headers as a list of string, with each item as 'HeaderKey: HeaderValue'
118+
119+
### get_content_length()
120+
121+
returns the request/response body length
122+
123+
### get_content_type()
124+
125+
returns the request/response body content type
126+
127+
### get_header(name)
128+
129+
returns the value of the specified request/response header
130+
131+
### get_url()
132+
133+
returns the url
134+
135+
### get_url_parameter(name)
136+
137+
get the value of a url query string item
138+
139+
140+
Exposed methods for IHttpRequest
141+
-
142+
143+
Exposed methods for IHttpResponse
144+
-

0 commit comments

Comments
 (0)