The follow Response keyword is used to handle redirection requests in HTTP, and common HTTP REDIRECT requests include HTTP Code 301 and 3,022 redirect requests, which represent a transfer of a URL address.
HTTP Code |
Description |
301 |
redirect:301 represents a permanent transfer (permanently Moved). |
60W |
redirect:302 represents a temporary transfer (temporarily Moved). |
Example 1: Call the Blog Park (http://www.cnblogs.com/) authentication Interface (https://passport.cnblogs.com/user/signin) for user login authentication, no cookie set on request HTTP code returns 302 when the HTTP header is used, and continues the request with the redirected URL after using the follow Response keyword.
Create Http Context passport.cnblogs.com Scheme=https
Set Request Header Referer https://passport.cnblogs.com/user/signin?ReturnUrl=http://i.cnblogs.com/
Set Request Body {"input1": "v+boqyku0zqxtauwxpgzc4yvvxwli6/za9u6hx2jxxdzipdxt2fzravj7air5ydssqeukyzfnb+ Komrnfzf5dzbhxn3foxhdq5oromddhh/zdxtuuqg/9ev4v4yyt9t8v9felmxs+bvrf2knzu35vtkaftqw8qn08tl0ggdzezy= "," Input2 ":" gak4vtm2i+a/6blhriu8/oeekjkav3sru/ds5l3o0bmd/xk6ped0vk8guls6/obv3dl+y8hub2ey9+ Po6ip53kisnkpoeu1y0p0acixmgk0jwcs+ydclgen0krvxnlo/ltcw1hrxvcrbraahrcezdt2otbye4frzkimshhqz+se= "," Remember ": False
Post/user/signin
Follow Response
${status} Get Response Status
${body} Get Response Body
Log ${body}
Log ${status}
Execution Result:
From the returned results, after the follow response keyword is used, the redirected URL continues with the request, and the last HTTP code returned is 200.
HTTP interface automation under robotframework Follow response keyword usage