How do I reply using a file in Fiddler Everywhere Free? - debugging

I am trying to replace a production js file on a site with a local copy of it so I can set my own event listeners and control the layout of the page as needed. A lot of old stackoverflow answers suggest using fiddler to do that, but apparently the UI has changed since then. I have added the file I want changed to the autoresponder list but it does not have an option to return a file. The closest I've gotten is return a manual response which I have to copy and paste a 50k line javascript file every time. Can I get a more detailed explanation of how to do this in the new UI or was this removed from the free version of Fiddler Everywhere?

You can use the Auto Responder and create a rule that uses an external file. The file could contain the whole mocked response including the references (or the content) of the JS script.
To achieve the above use the last action from the Action drop-down which is named Choose saved response file ... (see more about the actions in this article).

Related

delete uploaded file from folder using JMeter

I am sending a HTTP request to upload a file. And the request is setup like this:
uploadFile
And, the Directory Listing plugin pointing to a directory with all files and the request picks one file at a time. It works fine when run with one thread but, when i run in multiple threads, i see that already uploaded file is picked again to upload which leads to error.
I have added regular expression extrator to get the filename from the request body like this:
extract-filename-from-requestbody
And then, I am trying to use a post processor beanshell script to either delete the file from the folder or move to a different folder. But, not been successful. Need some help on this.
The first issue is i am not sure if i am extracting the value the right way. The value is to be got from request body and not request header. But, i dont see that option in the extractor.
Second, i am unable to use/retrieve the value from the extractor. Tried vars.get, vars.getObject and simply "${fileName}". Nothing works.
I don't think that deleting the file will help because Directory Listing Config reads the folder at the beginning of the test (see Execution Order chapter) so no matter whether the file is physically present or not JMeter will try to upload it
If you want to get unique files without repetitions just untick "Rewind on end of list" box:
This way each virtual user will read the next value so there will be no duplicates. When the last file will be used - the test will stop.
More information: Introducing the Directory Listing Config Plugin on JMeter
Also going forward consider using JSR223 Test Elements and Groovy language instead of Beanshell, it's the recommended option since JMeter 3.1

Firefox extension dev: howto fix wrong "Referer" in XMLHttpRequest

I am trying to program a simple Firefox (66.0 Quantum) Extension intended to download complete HLS video streams. The basic approach is to start video-playback using the page's regular UI functionality and to intercept the loading of respective HLS .m3u8-playlist files from within the extension's background-script (i.e. using "browser.webRequest.onBeforeRequest"). The extension similarily also intercepts the first "video-chunk" request triggered by the playlist (using "browser.webRequest.onSendHeaders") - so it knowns what the correct http-headers for respective "video-chunk" requests would need to look like.
permission-wise I am currently using these:
"permissions": [
"downloads", "activeTab", "webRequest", "webRequestBlocking", "<all_urls>"
],
Based on the above collected information, ideally the extension should be able to create correct XMLHttpRequest requests for all the "movie-chucks" found in the playlist and to ultimately download all those files. Obviously a respective long running "download" task should be performed in the background-script and once the above information has been collected there should be no need to still keep the original browser tab open.
Problem: Some of the servers that serve the movie-chunks apparently rely on the "Referer" (and maybe "Origin") header for some kind of access-control and the XMLHttpRequest instances created from within the background-script DO NOT allow to create the respective correct header (since it is a restricted field it cannot be manually set to the correct value).
The only workaround that I found so far leaves a lot to be desired: A content.XMLHttpRequest created within a content-script uses the correct headers and my background-script can delegate (via messaging) the respective file loading to the content-script (which is rather silly and means that the background-script process will fail if the original browser tab is closed during download).
Is there any way that allows to properly do/complete all the download logic on the background-script side (even after the originating browser tab has been closed)?

Firefox-Addon: Add search engine with varying URL and suggestions

my Firefox addon shall add a search engine, that
provides suggestions
gets its search template URL specified on runtime (i.e.: template URL depends on the preferences of the user)
And I don't see a way to do both at the same time.
I see two options to add a search engine:
addEngineWithDetails
addEngine
addEngineWithDetails() allows me to add a search engine with the template URL. But it does (apparently?) not allow to provide a suggestions URL.
addEngine() allows me to add a search engine that is specified in an XML file. But if have that file saved locally in my addon directory (e.g. chrome://example-engine/content/search.xml), how can I change the template URL on runtime? And using an online XML is an unsafe options since the internet connection could be broken or bad during the addon install.
First fo all, you're right, addEngineWithDetails does not support suggestions.
The way to go would be to use addEngine (and removeEngine).
As for the "dynamic" part of your question: While I didn't test it, the implementation seems to happily accept data: URIs. So you could:
Construct a data URI using whatever methods you like (even constructing a full XML DOM and serializing it).
Call addEngine with the data URI.
When the user changes a pref, remove the old engine, and construct a new one.

How to detect the last Docpad render pass?

Im currently writing a small Docpad plugin to output a documents contentRenderedWithoutLayouts into a separate .json file next to the .html version for loading it via an ajax request later.
The plugin works by overriding Baseplugin's render: (opts) -> method and doing a few checks whether we're rendering a document and to html.
I now noticed that this method gets called multiple times for some documents, which seems to be render pass related. So how can I detect the final render pass per document to avoid writing the .json multiple times per render?
Many Thanks
--
Edit:
found the answer after another look at Docpads events list: http://docpad.org/docs/events
The writeAfter event is the right place to get the final data and have the output directory tree set up so I can put my .json files next to the .html.
In case you're interested find the plugin here: https://github.com/field/docpad-plugin-jsonfragment
Another approach to this would be to use the serverExtend event, and write a router that detects if it is an ajax request (existance of the IS_XHR header) and then sends the necessary json data from that. This would require your hosting platform to support node.js as you'll be using the docpad server.

Effective way to debug a Google Apps Script Web App

I have had some experience writing container-bound scripts, but am totally new to web apps.
How do I debug (e.g. look at variable values, step through code etc) a web app? In a container bound script it was easy, because I could set breakpoints, use the apps script debugger - how do I go about this in a web page e.g. when I execute a doPost?
In his excellent book "Google Script", James Ferreira advocates setting up your own development environment with three browser windows; one for the code, one for the live view (in Publish, Deploy as web app, you are provided with a "latest code" link that will update the live view to the latest save when it is refreshed), and one for a spreadsheet that logs errors (using try/catch wrapped around bits of code you want to keep an eye on).
In Web Apps, even the most basic debugging of variables through Logger.log() does not work!
A great solution to have at least simple variable logging available is Peter Herrmann's BetterLog for Apps Script. It allows you to log into a spreadsheet (the same as your working spreadsheet or a separate one).
Installation is very simple - just add an external resource (see the Github readme) and a single line of code to override the standard Logger object:
Logger = BetterLog.useSpreadsheet('your-spreadsheet-key-goes-here');
Remember, that the spreedsheet that you give here as a parameter will be used for the logging output and thus must be writable by anybody!
BetterLog will create a new sheet called "Log" in the given spreadsheet and will write each log call into a separate row of that sheet.
So, for me, I debug the front-end using inspector, I haven't found a way to step through code yet, but you can use 'debugger' in your javascript (along with console.log) to stop the code and check variables.
to debug the backend, what I've been doing is to write my functions like
function test_doSomething(){
payload = "{item1: 100, item2: 200}" //<- copy paste from log file
backend_doSomething(payload)
}
function backend_doSomething(payload){
Logger.log(payload)
params = JSON.parse(payload)
...
}
Then after refreshing your project on the backend, you can look at executions, grab the payload from the log file, and paste it into your test_doSomething() function.
From there, you are re-creating the call that you want to debug and you can run that, stepping through the backend code as usual.

Resources