Error "DuplicateHeaderName" upon PUT to S3 Bucket

2

We are doing a PUT to an S3 bucket to upload JPG image files via our application. It seems that certain images are successful all of the time while others fail all of the time. None of these images are very large and I believe all are under 100 MB in size. The odd thing is that our code has not changed in many months, but this error started appearing very recently. Below is an example of the headers being sent (I do not see any duplicates), followed by the error returned. Does anyone have any advice on how to troubleshoot this issue?

Host = <redacted - S3 endpoint> Date = Thu, 09 Feb 2023 13:35:24 GMT Authorization = <redacted> Content-Type = image/jpeg Content-Length = 43142

<?xml version="1.0" encoding="UTF-8"?> <Error><Code>DuplicateHeaderName</Code><Message>Your request contains duplicate headers.</Message> <RequestId>RDJGYY1MH54ANV7W</RequestId> <HostId><redacted></HostId> </Error>

asked a year ago698 views
3 Answers
2

I was having the same issue and I contacted Amazon support about it.

They just replied to me and let me know that, at least in my case, the duplicate header was the "Host" header.

The library I was using manually added the Host header, but the underlying HTTP Client library it was using was also specifying a host header.

Upon removing that host header, the problem was resolved.

jesse
answered a year ago
  • Hey Jesse, thank you for replying. If you are using Alexandria Library [ORACLE PL/SQL], I will be sooo grateful if you can show me where was it manually adding the host header. I need to fix it on mine.

  • Thanks so much Jess,

    Jack - If you search for l_header_names(1) := 'Host'; (it is in numerous places) and comment out those lines and reindex the remaining headers it addresses the issue. e.g. under put object:

    /* l_header_names.extend; l_header_names(1) := 'Host'; l_header_values.extend; l_header_values(1) := get_host(p_bucket_name); */ l_header_names.extend; l_header_names(1) := 'Date'; l_header_values.extend; l_header_values(1) := l_date_str;

    l_header_names.extend; l_header_names(2) := 'Authorization'; l_header_values.extend; l_header_values(2) := l_auth_str;

    l_header_names.extend; l_header_names(3) := 'Content-Type'; l_header_values.extend; l_header_values(3) := nvl(p_content_type, 'application/octet-stream');

    l_header_names.extend; l_header_names(4) := 'Content-Length'; l_header_values.extend; l_header_values(4) := dbms_lob.getlength(p_object);

  • Blessed Gemma.

    Thank you for helping me to find the problem. Commenting the lines hasn't worked, but i just changed the l_header_names(1) from Host to Host1 and it worked.

    Thank you sooooooooo much, guys.

  • Hi, I'm sorry, the library I am using is not Oracle related at all, it's actually an old Erlang library and this was the fix: https://github.com/choptastic/erls3/blob/master/src/erls3server.erl#L377-L378

0

One of our developers fixed this. It had to do with the way Oracle RDBMS was creating the headers.

answered a year ago
  • It looks like we are having the same issue. Do you have any information about what your developer did to fix it? It would be very appreciated!

  • Running into the same issue. If you can share what you found, it would be much appreciated.

  • We're also experiencing this. The code hasn't changed for years, and suddenly throwing this error for more than half of the requests.

0

If anyone can help me to fix it i will be grateful.

Oracle APEX running on Autonomous Database Free Tier

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions