Skip to content

Commit

Permalink
alternate
Browse files Browse the repository at this point in the history
  • Loading branch information
SamRemis committed Aug 27, 2024
1 parent 2ebdba4 commit 21b9704
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
7 changes: 2 additions & 5 deletions botocore/data/s3/2006-03-01/service-2.sdk-extras.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"version": 1.0,
"merge": {
"metadata":{
"protocol":"s3",
"protocols":["s3"]
},
"shapes": {
"Expires":{"type":"timestamp"}
"Expires":{"type":"timestamp"},
"ExpiresString":{"type":"string"}
}
}
}
7 changes: 6 additions & 1 deletion botocore/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

import copy
import datetime
import logging
import os
Expand Down Expand Up @@ -271,12 +271,17 @@ def _do_get_response(self, request, operation_model, context):
'body': request.body,
},
)
operation_model = copy.deepcopy(operation_model)
service_id = operation_model.service_model.service_id.hyphenize()
event_name = f"before-send.{service_id}.{operation_model.name}"
responses = self._event_emitter.emit(event_name, request=request)
http_response = first_non_none_response(responses)
if http_response is None:
http_response = self._send(request)
self._event_emitter.emit(
f"before-parse.{service_id}.{operation_model.name}",
**{'response': http_response, 'operation_model': operation_model}
)
except HTTPClientError as e:
return (None, e)
except Exception as e:
Expand Down
18 changes: 18 additions & 0 deletions botocore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,23 @@ def parse_get_bucket_location(parsed, http_response, **kwargs):
region = root.text
parsed['LocationConstraint'] = region

def handle_expires_header(response, operation_model, **kwargs):
if output_shape := operation_model.output_shape:
if 'Expires' in output_shape.members:
expires_member = output_shape.members['Expires']
if expires_member.name == 'Expires':
expires_string_member = copy.deepcopy(expires_member)
expires_string_member.type_name = 'string'
expires_string_member.name = 'ExpiresString'
output_shape.members['ExpiresString'] = expires_string_member
try:
utils.parse_timestamp(response.headers.get('Expires'))
except (ValueError, RuntimeError):
del output_shape.members['Expires']
#TODO log a warning here




def document_s3_expires_shape(section, event_name, **kwargs):
# Updates the documentation for S3 operations that include the 'Expires' member
Expand Down Expand Up @@ -1237,6 +1254,7 @@ def remove_content_type_header_for_presigning(request, **kwargs):
('after-call.ec2.GetConsoleOutput', decode_console_output),
('after-call.cloudformation.GetTemplate', json_decode_template_body),
('after-call.s3.GetBucketLocation', parse_get_bucket_location),
('before-parse.s3.*', handle_expires_header),
('before-parameter-build', generate_idempotent_uuid),
('before-parameter-build.s3', validate_bucket_name),
('before-parameter-build.s3', remove_bucket_from_url_paths_from_model),
Expand Down
1 change: 0 additions & 1 deletion botocore/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,6 @@ def _handle_expires_timestamp(self, shape, timestamp):

PROTOCOL_PARSERS = {
'ec2': EC2QueryParser,
's3': S3Parser,
'query': QueryParser,
'json': JSONParser,
'rest-json': RestJSONParser,
Expand Down
1 change: 0 additions & 1 deletion botocore/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ def _default_serialize(self, xmlnode, params, shape, name):

SERIALIZERS = {
'ec2': EC2Serializer,
's3': RestXMLSerializer,
'query': QuerySerializer,
'json': JSONSerializer,
'rest-json': RestJSONSerializer,
Expand Down

0 comments on commit 21b9704

Please sign in to comment.