IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Delphi Discussion :

DELPHI 11.3 - Réponse REST : OK sur Delphi 11.1 / vide sur Delphi 11.3


Sujet :

Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2021
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2021
    Messages : 9
    Par défaut DELPHI 11.3 - Réponse REST : OK sur Delphi 11.1 / vide sur Delphi 11.3
    Bonjour,

    Nous observons une différence entre Delphi 11.1 et 11.3 sur les réponses REST, différence qui créé un dysfonctionnement sur un process de notre application en communication avec Microsoft Azure/Graph.

    Requête : "https://graph.microsoft.com/v1.0/me"

    Dans le RestDebogueur
    - Delphi 11.1 = le corps contient bien résultat attendu (Json)
    - Delphi 11.2 et 3 = le corps reste vide

    Avec PostMan le corps contient bien résultat attendu (Json), (idem Delphi 11.1).

    Après recherche dans le code entre les deux versions de Delphi, il apparaît que le code a évolué dans la procedure "TCustomRESTRequest.Execute" de l'unité REST.Client, lors du traitement du Charset et ContentType

    11.1 : REST.Client ligne 3253 à 3285
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
            
            LContentIsString := False;
            LEncoding := nil;
            try
              LLowerContentType := LowerCase(Client.HTTPClient.Response.ContentType);
              LCharSet := Client.HTTPClient.Response.CharSet;
              if LCharSet <> '' then
                LContentIsString := True
              else
              begin
                TMimeTypes.Default.GetTypeInfo(LLowerContentType, LExt, LMimeKind);
                // Skip if blank or 'raw'
                if (FClient.FallbackCharsetEncoding <> '') and
                   not SameText(REST_NO_FALLBACK_CHARSET, FClient.FallbackCharsetEncoding) then
                begin
                  // Skip some obvious binary types
                  if LMimeKind <> TMimeTypes.TKind.Binary then
                  begin
                    LEncoding := TEncoding.GetEncoding(FClient.FallbackCharsetEncoding);
                    LContentIsString := True;
                  end;
                end
                else
                begin
                  // Even if no fallback, handle some obvious string types
                  if LMimeKind = TMimeTypes.TKind.Text then
                    LContentIsString := True;
                end;
              end;
              if LContentIsString then
                LContent := FClient.HTTPClient.Response.ContentAsString(LEncoding);
            finally
              LEncoding.Free;
            end;

    11.3 : REST.Client ligne 3269 à 3317
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
            LContentIsString := False;
            LEncoding := nil;
            LTryFallback := True;
            try
              LLowerContentType := LowerCase(Client.HTTPClient.Response.ContentType);
              if LLowerContentType <> '' then
                TMimeTypes.Default.GetTypeInfo(LLowerContentType, LExt, LMimeKind)
              else
                LMimeKind := TMimeTypes.TKind.Text;
              // Try "charset", skip if blank
              if Client.HTTPClient.Response.CharSet <> '' then
              begin
                LTryFallback := False;
                // Handle some obvious text types
                if LMimeKind = TMimeTypes.TKind.Text then
                begin
                  try
                    LEncoding := TEncoding.GetEncoding(Client.HTTPClient.Response.CharSet);
                    LContentIsString := True;
                  except
                    LTryFallback := True;
                  end;
                end;
              end;
              if LTryFallback then
              begin
                // Try fallback charset, skip if blank or 'raw'
                if (FClient.FallbackCharsetEncoding <> '') and
                   not SameText(REST_NO_FALLBACK_CHARSET, FClient.FallbackCharsetEncoding) then
                begin
                  // Handle some obvious text types
                  if LMimeKind = TMimeTypes.TKind.Text then
                  begin
                    LEncoding := TEncoding.GetEncoding(FClient.FallbackCharsetEncoding);
                    LContentIsString := True;
                  end;
                end
                else
                // Even if no fallback, handle some obvious text types
                begin
                  if LMimeKind = TMimeTypes.TKind.Text then
                    LContentIsString := True;
                end;
              end;
              if LContentIsString then
                LContent := FClient.HTTPClient.Response.ContentAsString(LEncoding);
            finally
              LEncoding.Free;
            end;
    Dans le 1° cas, le test du CharSet nous envoie directement sur la récupération du Content
    Ce que nous attendons

    Dans le 2° cas, le ContentType est analysé avant le test du CharSet (dans notre cas "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false")
    lorsque le ContentType est
    - rigoureusement égal à 'application/json', "LMimeKind" est positionné sur "Text"
    - n'est pas rigoureusement égal, "LMimeKind" est positionné sur "Undifined" et le Content n'est pas récupéré et reste vide

    Autrement dit il manque un split du Content-type avant analyse, en l'état le retour du Content-type par Graph pose problème, nous avons essayé de voir comment le rendre plus concis ("accept=application/json") sans succès.

    En espérant partager notre expérience et en remerciant ceux qui se pencheront éventuellement dessus.

  2. #2
    Membre Expert
    Avatar de pprem
    Homme Profil pro
    MVP Embarcadero - formateur&développeur Delphi, PHP et JS
    Inscrit en
    Juin 2013
    Messages
    1 876
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : MVP Embarcadero - formateur&développeur Delphi, PHP et JS
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2013
    Messages : 1 876
    Par défaut
    Bonsoir

    Là, c'est clairement reproductible et une regression par rapport au fonctionnement préalable, il faut ouvrir un ticket sur https://quality.embarcadero.com

    Idéalement il faudrait fournir une copie du endpoint ou des captures d'écran de ce qu'on reçoit/voit sur Postman et ce que voit Delphi.

  3. #3
    Membre Expert
    Avatar de pprem
    Homme Profil pro
    MVP Embarcadero - formateur&développeur Delphi, PHP et JS
    Inscrit en
    Juin 2013
    Messages
    1 876
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : MVP Embarcadero - formateur&développeur Delphi, PHP et JS
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2013
    Messages : 1 876
    Par défaut
    J'ai vu passer d'autres remarques sur le même sujet, toujours avec GraphQL, y a un truc louche.

  4. #4
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2021
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2021
    Messages : 9
    Par défaut
    Bonjour Patrick,

    Merci pour ton retour, nous allons ouvrir un incident comme tu nous l'as conseillé,

    Bonne journée

  5. #5
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    n'hésite pas à donner ici le lien vers QP et je remonterais cette régression ... quand c'est tout neuf c'est parfois plus facile de remettre le nez dedans mais après c'est eux qui décident.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  6. #6
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 638
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 638
    Billets dans le blog
    65
    Par défaut
    Ça me rappelle un mauvais souvenir plus ou moins identique avec la version 10.4 (RSP-32297) !

  7. #7
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2021
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2021
    Messages : 9
    Par défaut
    Bonjour Paul,

    voici le lien vers qp : https://quality.embarcadero.com/browse/RSP-40757

    bonne journée.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Package qui reste bloqué sur un data conversion
    Par remsrock dans le forum MS SQL Server
    Réponses: 0
    Dernier message: 26/11/2008, 11h27
  2. Réponses: 2
    Dernier message: 22/02/2008, 14h20
  3. PC reste figé sur "Bienvenue" 1m30 !
    Par devlopassion dans le forum Windows XP
    Réponses: 12
    Dernier message: 24/10/2006, 16h56
  4. F.A.Q : les réponses à vos questions sur le nouveau forum
    Par Marc Lussac dans le forum Evolutions du club
    Réponses: 8
    Dernier message: 04/05/2006, 22h04
  5. Réponses: 9
    Dernier message: 30/08/2005, 09h17

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo