Jump to content
Mark Williams

ENetHTTPRequestException exception Error adding header: (87) The parameter is incorrect.

Recommended Posts

This is in connection with the AddHeader function of the IHTTPRequest. I'm trying to add a multiline text which also contains numerous characters such as = signs etc. I am getting the above error as a result. Is it even possible to do this? Should I be formatting the text in some way before adding it? UrlEncode?

Share this post


Link to post

Hi Thanks,

 

As far as I can see (and with my limited understanding of the protocols) it is compliant with the requirements for headers. Each line break is coded +Chr(32)+sLineBreak; There are no line breaks inserted other than in this manner, but I still get the error.

 

Does anyone know of any function for encoding text in away that will satisfy the protocol?

Share this post


Link to post
Guest

Why do you need to send "multiline" text in the header? It sounds like food for the payload.

Anyway, my interpretation of the link above is that each key-value pair in the headers should NOT contain CRLF.

So Base64 encoding would be my first labrat.

Share this post


Link to post
5 hours ago, Dany Marmur said:

Why do you need to send "multiline" text in the header? It sounds like food for the payload.

Anyway, my interpretation of the link above is that each key-value pair in the headers should NOT contain CRLF.

So Base64 encoding would be my first labrat.

I tried Base64. This may have worked, but I think I'm running into a limitation as to permissible size of header. 

 

I absolutely agree that it is food for the payload, but I have tried and failed to submit/receive content using THTTPClient and TWebRequest components.

 

My code for submitting the component is below, but when I try and access the TWebRequest's content it remains stubbornly empty.

 

  FHttpClient:=THttpClient.Create;
  try
    With FHttpClient do
      begin  
        data:=TStringStream.Create;
        try
          data.WriteString(content);
          ContentType:='text/html';
          Accept:='text/plain, */*';
          AcceptCharSet:='utf-8';

          LResponse:=FHttpClient.Post(Script, data);          
        finally
          data.Free;
        end;
      end;
  

I have now resorted to submitting it as multipartdata, which works, but seems overkill just to submit a string.

Share this post


Link to post
Guest
6 hours ago, Mark Williams said:

I have now resorted to submitting it as multipartdata, which works, but seems overkill just to submit a string.

Hmmm... that sound like a cry from the 80's. Noooo... daily millions, billions and billions of requests and responses are distributed.

IMHO your intention is called "premature optimisation". Multipart works fine. 

 

If you are at the stage where you can do some real-world sims and tests, do. I would even bet moneys that you will not much performance difference. But the only way to know is to measure.

 

1; stability, extendability, maintainability, security, and so on and so forth.

2: perform better that the competition (say) they do. The comparison will judge between apples and peaches anyway.

 

6 hours ago, Mark Williams said:

but I have tried and failed to submit/receive content using THTTPClient and TWebRequest

I do not use these myself. Sorry. But do you write both server and client? Or do you have more to consider?

Please provide some more information about you goals and prerequisites and i'm sure you will receive good advice from the gurus.

Share this post


Link to post

Thanks. I do write both server and client. I have it working with multiformdata at moment and am going to leave it at that for now as this is a fairly minor part of a hefty development and I have managed to get myself bogged down in it. I will revisit it when I have a bit more time and do some research online. But thanks for all your help.

Share this post


Link to post
Guest
4 hours ago, Mark Williams said:

But thanks for all your help.

You are MOST welcome!

 

Generally in this forum, you can also credit people by clicking on the heart of the post that helped you and select an appropriate "social media icon" (or whatever ther are called these days".

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×