-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
Upload with charset #431
Upload with charset #431
Conversation
depends on #348 |
@jlevers I think it's OK (got some trouble with markdown auto toc) |
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.
A few comments :) sorry it took me so long!
lib/Document.php
Outdated
public function upload($feedData, ?string $charset = null): void { | ||
$response = $this->client->put($this->url, [ | ||
RequestOptions::HEADERS => [ | ||
"content-type" => $this->contentType, | ||
"content-type" => self::get_content_type_with_charset($this->contentType, $charset), | ||
"host" => parse_url($this->url, PHP_URL_HOST), | ||
], |
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.
if we just give the new parameter a default of 'utf-8'
, we can remove a bunch of code, because then the 'content-type' header can become "$contentType; charset=$charset"
, and the get_content_type_with_charset
method can be removed altogether :)
README.md
Outdated
... | ||
// Create feed document | ||
$createFeedDocSpec = new Feeds\CreateFeedDocumentSpecification([ | ||
'content_type' => SellingPartnerApi\Document::get_content_type_with_charset($feedType['contentType'], $charset)] |
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.
given my below comment, i think this documentation will need to be changed.
i think that a static method for retrieving a content type with a charset should be put in ContentType.php
, something like this:
public static function withCharset(string $contentType, string $charset): string
{
return "{$contentType}; charset={$charset}";
}
@jlevers |
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.
Looks good, thank you!
I'm reverting this until the next major version. It's a breaking change because of the usage differences when creating a new feed document. This has led to a lot of people encountering issues and needing to downgrade (see #486). |
oops using a |
Would you mind making a new PR with a |
OC no pb thx |
Proposition for #336