sets everything needed for the request
(self, url, get, post, referer, cookies, multipart=False)
| 162 | self.c.setopt(pycurl.COOKIELIST, "") |
| 163 | |
| 164 | def setRequestContext(self, url, get, post, referer, cookies, multipart=False): |
| 165 | """ sets everything needed for the request """ |
| 166 | |
| 167 | self.rep = cStringIO.StringIO() |
| 168 | |
| 169 | url = myquote(url) |
| 170 | |
| 171 | if get: |
| 172 | get = urlencode(get) |
| 173 | url = "%s?%s" % (url, get) |
| 174 | |
| 175 | self.c.setopt(pycurl.URL, url) |
| 176 | self.c.lastUrl = url |
| 177 | |
| 178 | if post: |
| 179 | self.c.setopt(pycurl.POST, 1) |
| 180 | if not multipart: |
| 181 | if type(post) == unicode: |
| 182 | post = str(post) #unicode not allowed |
| 183 | elif type(post) == str: |
| 184 | pass |
| 185 | else: |
| 186 | post = myurlencode(post) |
| 187 | |
| 188 | self.c.setopt(pycurl.POSTFIELDS, post) |
| 189 | else: |
| 190 | post = [(x, y.encode('utf8') if type(y) == unicode else y ) for x, y in post.iteritems()] |
| 191 | self.c.setopt(pycurl.HTTPPOST, post) |
| 192 | else: |
| 193 | self.c.setopt(pycurl.POST, 0) |
| 194 | |
| 195 | if referer and self.lastURL: |
| 196 | self.c.setopt(pycurl.REFERER, str(self.lastURL)) |
| 197 | |
| 198 | if cookies: |
| 199 | self.c.setopt(pycurl.COOKIEFILE, "") |
| 200 | self.c.setopt(pycurl.COOKIEJAR, "") |
| 201 | self.getCookies() |
| 202 | |
| 203 | |
| 204 | def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False, multipart=False, decode=False): |
no test coverage detected