Skip to content

Commit 6792776

Browse files
committed
FEAT: added possibility to set User-Agent in HTTP scheme
One can now for example pretend that HTTP requests are coming from Chrome on Windows 10, when use this code before reading URL(s): ``` system/schemes/http/user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" ``` This may be useful, because for example Google is serving different results, when default "REBOL" user agent is used.
1 parent eef497e commit 6792776

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mezz/prot-http.r

+4-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ do-request: func [
249249
] [
250250
form spec/host
251251
]
252-
User-Agent: "REBOL"
252+
User-Agent: any [system/schemes/http/User-Agent "REBOL"]
253253
] spec/headers
254254
port/state/state: 'doing-request
255255
info/headers: info/response-line: info/response-parsed: port/data:
@@ -728,6 +728,9 @@ sys/make-scheme [
728728
either port/data [length? port/data] [0]
729729
]
730730
]
731+
User-Agent: none
732+
;@@ One can set above value for example to: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
733+
;@@ And so pretend that request is coming from Chrome on Windows10
731734
]
732735

733736
sys/make-scheme/with [

0 commit comments

Comments
 (0)