[weboob] [PATCH 1/1] new module openedx

Simon Lipp laiquo at hwold.net
Wed Feb 17 10:28:28 CET 2016


>> I would appreciate an advice on how to do properly what I did in an ugly
>> way in browser.py:62
>>
>> (basically, how to add a specific header (X-Requested-With) only for two
>> specific URLs (browser.threads and brower.messages)
>>
> I don't think it's especially ugly the way you did it.
>
> There's no way to specify default headers for a page, but you can always
> request them explicitly:
>
> browser.location(browser.mypage.build(), headers={'Header-Name':
> 'Header-Value'})
I was more thinking of a way to find which URL triggered the request, so 
I could do something like

     if self.threads.match(req) or self.messages.match(req): 
req.headers.setdefault(...)

I see that there’s already such a match method in URL, but I’m not 
exactly sure how req.url and URL.match works with baseurl. Looks like 
URL.match always try to prepend a base url ; but I’m unsure if req.url 
is guaranteed to always be a full url (domain + path + query-string) or 
can sometimes be just a path.


More information about the weboob mailing list