-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(browser): allow save source as raw content #121
Conversation
375f10c
to
4cd2e7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood the issue (didn't realize you actually wanted to save a raw zip file).
As an alternative to the $raw
parameter, what do you think about only adding the meta-information if content type is text/*
?
This way the saved file would always be valid to open in your OS's explorer. docx/xlsx/whatever
This would no longer add this meta-information to json so I'm not sure about this one... (@nikophil, wdyt?)
@kbond I agree, we can base the raw process on the content type. For json, as the content type is |
Sounds good! For the |
not sure about the parameter if we implement the suggestion based on content type: if we have something like |
06864f9
to
5ddaf68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good for me, except the small comment I suggested
5ddaf68
to
9a53f90
Compare
I rewrite the code to put the metadata prepended to the content under a condition via a global flag named The only exception to this, is the call of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should forgo the global env variable for now.
Correct me if I'm wrong but when using the PHPUnit extension, it will no longer output the meta info in the generated files. I believe this is useful to help debug what path/headers caused the problem.
I don't believe there is any harm in always having the metadata in text/*
files. My only question was for .json files as this doesn't output valid json... I am thinking this is ok as I believe most people would open .json files in a text editor/ide.
To summarize, I think we should always add metadata for text/* and application/json content types. All others should be the raw values.
9a53f90
to
1289278
Compare
I'm actually writing tests, and I expect to be able to compare files to saved sources from Browser (zip, html, jpg, json). As I need to compare saved sources to static files I have in my tests folder, I would like to disable completely the metadata prepended to the sources. But, in another hand, I would like to enable those if I need to debug something. @nikophil WDYT about this general flag? |
Got it, didn't realize you had a real use-case. I'm sort of still thinking a |
Agreed. What I am suggesting is to, by default, only add metadata to html,xml,plain-text/json content types. |
To make a decision, I think we must retrieve the original reason of the metadata presence? Was there a specific reason? |
It's purpose is to make debugging x/html/json errors easier when:
(2) above is I suppose the only hard reason to actually write the files with the metadata included. If you are calling |
As it's for failure/error cases, even in CI, I think the Set to |
Yes, that's a fair point. I still think any non-text/json content should never have metadata added as it corrupts the file. But I'm fine rolling with this as is for now as, by default, this won't happen anymore. |
I see your point, so I can also add a condition (in addition to |
Sure, we'll have to be loose with the check I think: |
1289278
to
f85baa2
Compare
Finally, I've added 2 conditions to writing metadata : Beside, we decided to never prepend source content with metadata if PantherBrowser is used (as we can't check on response headers with Panther response). |
Thanks @welcoMattic! |
Fix: #120
We can now save source as raw, and make assertions on file like zip or any other binary format.
NOTE: we could improve assertions on the zip file itself by requiring
ext-zip
and use\ZipArchive
class to open zip.