I am using nsIHttpChannel in an observer to modify outgoing request headers, which works fine. According to the API, however, it appears I cannot simply remove a header (as I can in Chrome), I can only give it an empty value via setEmptyRequestHeader(). Is there some other way to completely remove the header from the request ?
The documentation for setRequestHeader() states
If aValue is empty and aMerge is false, the header will be cleared.
Related
I want to define a custom static url for my connections in Postman:
Then I tried calling a GET request by that custom static url:
But I get Could not send request message because the variable is not defined somehow:
But I don't know why it can not be found since I have defined at Variables section of the Collection and called it like this:
{{staticUrl}}/api/users?page=2
So what's going wrong here? I would really appreciate if you share any idea about this with me...
Make sure you save your collection and then move to the actual request tab. I forgot to do the same and Postman cannot resolve the variable.
Also make sure not to press enter button after creating your variable name. It causes Postman to register carriage return symbol ⏎ and thus creates a key with an additional character.
I'm working on a small-scale instagram scraping project mainly using selenium and the python requests module. I discovered that when the Request Header changes for www.instagram.com, the text that I get from using
requests.get("https://www.instagram.com/<address>/?__a=1")
Returns the HTML code for the webpage. Instead I was expecting it to be the json text containing post details. Currently, it works fine if I change the headers manually.
How do I automatically get the request header using selenium or requests? I'm expecting to get the text labeled in the image attached:
www.instagram.com Request Header
Thank you.
import requests
response = requests.get("https://www.instagram.com/<address>/?__a=1")
print(response.status_code)
print(response.headers)
print(response.json())
As I see in the headers printed out on to console, there is a set-cookie header. If this is something that you are looking for, then you may use this line to extract only this header:
print(resp.headers['Set-Cookie'])
I have a PayPal button which upon checkout completion redirects the user back to the homepage but in the background opens another php page which does a couple of things including updating some databases etc. However in it it I'd also like to perform a rest API request.
http://your-server/rest/createUser?username=testuser&password=testpassword
Here is the URL I need to fire and I'm not too bothered about reading the contents of this to be honest, it respond an XML file saying status OK or error messages but I don't need this... All I want to do is access the URL. This works from a browser, but when I try to use
$apicall = file_get_contents("http://your-server/rest/createUser?username=testuser&password=testpassword");
It doesn't work... Any thought ?
For file_get_contents() to work correctly any special characters have to be encoded.
$url = 'http://your-server....';
$encodedUrl = urlencode($url);
$apicall = file_get_contents($encodedUrl);
The other thing to check is that allow_url_fopen php.ini setting is set to true. (It is by default).
I have the following method that creates a cookie in the page's response. Immediately after I create the cookie, I checked to see what the value was and it was blank. Is this normal behavior? How can I check the response for a cookie after it has been added?
When I monitor the HTTP response, the cookie is there. When I use the Firefox Web Developer Toolbar to view the cookie, it is there. However, it doesnt appear to be present in the Response.Cookies collection. How do I access it?
Dim c As New HttpCookie("prpg")
c.Expires = DateTime.Now.AddYears(10)
c.Value = value
_page.Response.Cookies.Add(c)
_page.Response.Cookies("prpg").Value 'String.Empty
You can only write to Response not read from it. So I suppose it is not possible to read cookies too.
I'm doing some work with PyQt4 and QtWebKit, and in the web page request need to send a custom "Host" header along with the standard HTTP request. I'm not seeing any options for adding custom headers to the request, but this is all new to me so I hope I'm missing something. I'm looking here:
http://doc.qt.digia.com/4.6/qwebsettings.html
Any advice would be greatly appreciated.
You can set headers on the QNetworkRequest that is sent:
QNetworkRequest request;
request.setUrl(QUrl("http://qt.nokia.com"));
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
To use that custom request when loading a page, use the overloaded load function:
myWebView->load(request);
If you want to apply this to all requests QtWebKit makes, you can subclass QNetworkAccessManager and reimplement its createRequest() function to modify headers accordingly.